2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-29 13:07:50 +00:00

[1964] small cleanups for checkExcessPlaceholders.

- style fixes
- constify (also for replacePlaceholder)
- make sure all parameters are used regardless of ENABLE_LOGGER_CHECKS
This commit is contained in:
JINMEI Tatuya 2012-05-08 15:23:06 -07:00
parent 6c0da87a7b
commit 25f0bb96dd

View File

@ -25,7 +25,7 @@ void
replacePlaceholder(string* message, const string& arg, replacePlaceholder(string* message, const string& arg,
const unsigned placeholder) const unsigned placeholder)
{ {
string mark("%" + lexical_cast<string>(placeholder)); const string mark("%" + lexical_cast<string>(placeholder));
size_t pos(message->find(mark)); size_t pos(message->find(mark));
if (pos != string::npos) { if (pos != string::npos) {
do { do {
@ -48,17 +48,19 @@ replacePlaceholder(string* message, const string& arg,
} }
void void
checkExcessPlaceholders(string* message, unsigned int placeholder) checkExcessPlaceholders(string* message, unsigned int placeholder) {
{ const string mark("%" + lexical_cast<string>(placeholder));
#ifdef ENABLE_LOGGER_CHECKS const size_t pos(message->find(mark));
string mark("%" + lexical_cast<string>(placeholder));
size_t pos(message->find(mark));
if (pos != string::npos) { if (pos != string::npos) {
#ifdef ENABLE_LOGGER_CHECKS
// Excess placeholders were found, so throw an exception // Excess placeholders were found, so throw an exception
isc_throw(MismatchedPlaceholders, isc_throw(MismatchedPlaceholders,
"Excess logger placeholders still exist in message: " << *message); "Excess logger placeholders still exist in message: "
} << *message);
#else
message->append(" @@Excess logger placeholders still exist@@");
#endif /* ENABLE_LOGGER_CHECKS */ #endif /* ENABLE_LOGGER_CHECKS */
}
} }
} }