#include "config.h"
#include <log/log_formatter.h>
+#include <cassert>
+
using namespace std;
using namespace boost;
const string mark("%" + lexical_cast<string>(placeholder));
const size_t pos(message->find(mark));
if (pos != string::npos) {
+ // Excess placeholders were found. If we enable the harsh check,
+ // abort it. Note: ideally we'd like to throw MismatchedPlaceholders,
+ // but we can't at least for now because this function is called from
+ // the Formatter's destructor.
#ifdef ENABLE_LOGGER_CHECKS
- // Excess placeholders were found, so throw an exception
- isc_throw(MismatchedPlaceholders,
- "Excess logger placeholders still exist in message: "
- << *message);
+ assert("Excess logger placeholders still exist in message" == NULL);
#else
message->append(" @@Excess logger placeholders still exist@@");
#endif /* ENABLE_LOGGER_CHECKS */
TEST_F(FormatterTest, mismatchedPlaceholders) {
EXPECT_DEATH({
isc::util::unittests::dontCreateCoreDumps();
- Formatter(isc::log::INFO, s("Missing the first %2"), this).arg("missing").arg("argument");
+ Formatter(isc::log::INFO, s("Missing the first %2"), this).
+ arg("missing").arg("argument");
}, ".*");
EXPECT_DEATH({
isc::util::unittests::dontCreateCoreDumps();
- Formatter(isc::log::INFO, s("Too many arguments in %1 %2"), this).arg("only one");
+ Formatter(isc::log::INFO, s("Too many arguments in %1 %2"), this).
+ arg("only one");
}, ".*");
}
#endif /* EXPECT_DEATH */