Unverified Commit 9187be72 authored by Andrei Pavel's avatar Andrei Pavel
Browse files

[#562] mention mark and argument in logger error

parent 7e47dc28
...@@ -29,19 +29,17 @@ replacePlaceholder(std::string& message, const string& arg, ...@@ -29,19 +29,17 @@ replacePlaceholder(std::string& message, const string& arg,
message.replace(pos, mark.size(), arg); message.replace(pos, mark.size(), arg);
pos = message.find(mark, pos + arg.size()); pos = message.find(mark, pos + arg.size());
} while (pos != string::npos); } while (pos != string::npos);
} } else {
#ifdef ENABLE_LOGGER_CHECKS #ifdef ENABLE_LOGGER_CHECKS
else {
// We're missing the placeholder, so throw an exception // We're missing the placeholder, so throw an exception
isc_throw(MismatchedPlaceholders, isc_throw(MismatchedPlaceholders, "Missing logger placeholder '" << mark << "' for value '"
"Missing logger placeholder in message: " << message); << arg << "' in message '"
} << message << "'");
#else #else
else {
// We're missing the placeholder, so add some complain // 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 */ #endif /* ENABLE_LOGGER_CHECKS */
}
} }
void void
...@@ -57,10 +55,11 @@ checkExcessPlaceholders(std::string& message, ...@@ -57,10 +55,11 @@ checkExcessPlaceholders(std::string& message,
#ifdef ENABLE_LOGGER_CHECKS #ifdef ENABLE_LOGGER_CHECKS
// Also, make sure we print the message so we can identify which // Also, make sure we print the message so we can identify which
// identifier has the problem. // identifier has the problem.
cerr << "Message " << message << endl; cerr << "Excess logger placeholder '" << mark << "' still exists in message '" << message
assert("Excess logger placeholders still exist in message" == NULL); << "'." << endl;
assert(false);
#else #else
message.append(" @@Excess logger placeholders still exist@@"); message.append(" @@Excess logger placeholder " + mark + " still exists@@");
#endif /* ENABLE_LOGGER_CHECKS */ #endif /* ENABLE_LOGGER_CHECKS */
} }
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment