From cc9a156387fc300b0086e85b370ea1ac599ef431 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 25 Feb 2015 20:24:36 +0000 Subject: Reduce verbosity of testcommon by hiding some log messages. --- lib/common/Configuration.cpp | 16 +++++++++++----- lib/common/Configuration.h | 9 +++++++++ lib/common/ExcludeList.cpp | 11 +++++++---- 3 files changed, 27 insertions(+), 9 deletions(-) (limited to 'lib/common') diff --git a/lib/common/Configuration.cpp b/lib/common/Configuration.cpp index f49f3c6e..8ce8d389 100644 --- a/lib/common/Configuration.cpp +++ b/lib/common/Configuration.cpp @@ -34,6 +34,8 @@ inline bool iw(int c) static const char *sValueBooleanStrings[] = {"yes", "true", "no", "false", 0}; static const bool sValueBooleanValue[] = {true, true, false, false}; +const ConfigurationCategory ConfigurationVerify::VERIFY_ERROR("VerifyError"); + ConfigurationVerifyKey::ConfigurationVerifyKey ( std::string name, @@ -212,8 +214,8 @@ std::auto_ptr Configuration::LoadAndVerify( if(!rErrorMsg.empty()) { // An error occured, return now - BOX_ERROR("Error in Configuration::LoadInto: " << - rErrorMsg); + BOX_LOG_CATEGORY(Log::ERROR, ConfigurationVerify::VERIFY_ERROR, + "Error in Configuration::LoadInto: " << rErrorMsg); return std::auto_ptr(0); } @@ -222,8 +224,11 @@ std::auto_ptr Configuration::LoadAndVerify( { if(!apConfig->Verify(*pVerify, std::string(), rErrorMsg)) { - BOX_ERROR("Error verifying configuration: " << - rErrorMsg); + BOX_LOG_CATEGORY(Log::ERROR, + ConfigurationVerify::VERIFY_ERROR, + "Error verifying configuration: " << + rErrorMsg.substr(0, rErrorMsg.size() > 0 + ? rErrorMsg.size() - 1 : 0)); return std::auto_ptr(0); } } @@ -425,7 +430,8 @@ const std::string &Configuration::GetKeyValue(const std::string& rKeyName) const if(i == mKeys.end()) { - BOX_ERROR("Missing configuration key: " << rKeyName); + BOX_LOG_CATEGORY(Log::ERROR, ConfigurationVerify::VERIFY_ERROR, + "Missing configuration key: " << rKeyName); THROW_EXCEPTION(CommonException, ConfigNoKey) } else diff --git a/lib/common/Configuration.h b/lib/common/Configuration.h index 4828b315..e6498e80 100644 --- a/lib/common/Configuration.h +++ b/lib/common/Configuration.h @@ -27,6 +27,14 @@ enum ConfigTest_IsBool = 32 }; +class ConfigurationCategory : public Log::Category +{ + public: + ConfigurationCategory(const std::string& name) + : Log::Category(std::string("Configuration/") + name) + { } +}; + class ConfigurationVerifyKey { public: @@ -75,6 +83,7 @@ public: const ConfigurationVerifyKey *mpKeys; int Tests; void *TestFunction; // set to zero for now, will implement later + static const ConfigurationCategory VERIFY_ERROR; }; class FdGetLine; diff --git a/lib/common/ExcludeList.cpp b/lib/common/ExcludeList.cpp index 213c4f8e..f101782a 100644 --- a/lib/common/ExcludeList.cpp +++ b/lib/common/ExcludeList.cpp @@ -139,9 +139,10 @@ void ExcludeList::AddDefiniteEntries(const std::string &rEntries) if (entry.size() > 0 && entry[entry.size() - 1] == DIRECTORY_SEPARATOR_ASCHAR) { - BOX_WARNING("Exclude entry ends in path " - "separator, will never match: " - << entry); + BOX_LOG_CATEGORY(Log::WARNING, + ConfigurationVerify::VERIFY_ERROR, + "Exclude entry ends in path separator, " + "will never match: " << entry); } mDefinite.insert(entry); @@ -198,7 +199,9 @@ void ExcludeList::AddRegexEntries(const std::string &rEntries) { char buf[1024]; regerror(errcode, pregex, buf, sizeof(buf)); - BOX_ERROR("Invalid regular expression: " << + BOX_LOG_CATEGORY(Log::ERROR, + ConfigurationVerify::VERIFY_ERROR, + "Invalid regular expression: " << entry << ": " << buf); THROW_EXCEPTION(CommonException, BadRegularExpression) } -- cgit v1.2.3