]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#562] mention mark and argument in logger error
authorAndrei Pavel <andrei@isc.org>
Fri, 6 May 2022 05:56:00 +0000 (08:56 +0300)
committerAndrei Pavel <andrei@isc.org>
Fri, 20 May 2022 17:38:56 +0000 (20:38 +0300)
src/lib/log/log_formatter.cc

index dce7fe990a132289b0afff490ab0f87b6d4705f8..c568f86a9166e85832de6b545891d600b436c998 100644 (file)
@@ -29,19 +29,17 @@ replacePlaceholder(std::string& message, const string& arg,
             message.replace(pos, mark.size(), arg);
             pos = message.find(mark, pos + arg.size());
         } while (pos != string::npos);
-    }
+    } else {
 #ifdef ENABLE_LOGGER_CHECKS
-    else {
         // We're missing the placeholder, so throw an exception
-        isc_throw(MismatchedPlaceholders,
-                  "Missing logger placeholder in message: " << message);
-    }
+        isc_throw(MismatchedPlaceholders, "Missing logger placeholder '" << mark << "' for value '"
+                                                                         << arg << "' in message '"
+                                                                         << message << "'");
 #else
-    else {
         // We're missing the placeholder, so add some complain
-        message.append(" @@Missing placeholder " + mark + " for '" + arg + "'@@");
-    }
+        message.append(" @@Missing placeholder '" + mark + "' for value '" + arg + "'@@");
 #endif /* ENABLE_LOGGER_CHECKS */
+    }
 }
 
 void
@@ -57,10 +55,11 @@ checkExcessPlaceholders(std::string& message,
 #ifdef ENABLE_LOGGER_CHECKS
         // Also, make sure we print the message so we can identify which
         // identifier has the problem.
-        cerr << "Message " << message << endl;
-        assert("Excess logger placeholders still exist in message" == NULL);
+        cerr << "Excess logger placeholder '" << mark << "' still exists in message '" << message
+             << "'." << endl;
+        assert(false);
 #else
-        message.append(" @@Excess logger placeholders still exist@@");
+        message.append(" @@Excess logger placeholder " + mark + " still exists@@");
 #endif /* ENABLE_LOGGER_CHECKS */
     }
 }