summaryrefslogtreecommitdiffstats
path: root/src/Core/LogManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Core/LogManager.cpp')
-rw-r--r--src/Core/LogManager.cpp37
1 files changed, 21 insertions, 16 deletions
diff --git a/src/Core/LogManager.cpp b/src/Core/LogManager.cpp
index af3e0ba..4a4cc0d 100644
--- a/src/Core/LogManager.cpp
+++ b/src/Core/LogManager.cpp
@@ -42,23 +42,28 @@ void LogManager::ConsoleLogger::logMessageDirect(MessageCategory /*category*/, M
}
-LogManager::MessageLevel LogManager::parseLevel(const std::string &str) throw (Exception) {
- if(str.empty())
+LogManager::MessageLevel LogManager::parseLevel(const UnicodeString &str) throw (Exception) {
+ static const UnicodeString DEBUG_LEVEL("debug");
+ static const UnicodeString VERBOSE_LEVEL("verbose");
+ static const UnicodeString DEFAULT_LEVEL("default");
+ static const UnicodeString WARNING_LEVEL("warning");
+ static const UnicodeString ERROR_LEVEL("error");
+ static const UnicodeString CRITICAL_LEVEL("critical");
+
+ if(str.isEmpty())
return Logger::LOG_DEFAULT;
- std::string lowerStr = boost::algorithm::to_lower_copy(str);
-
- if(lowerStr == "debug")
+ if(str.caseCompare(DEBUG_LEVEL, 0) == 0)
return Logger::LOG_DEBUG;
- else if(lowerStr == "verbose")
+ else if(str.caseCompare(VERBOSE_LEVEL, 0) == 0)
return Logger::LOG_VERBOSE;
- else if(lowerStr == "default")
+ else if(str.caseCompare(DEFAULT_LEVEL, 0) == 0)
return Logger::LOG_DEFAULT;
- else if(lowerStr == "warning")
+ else if(str.caseCompare(WARNING_LEVEL, 0) == 0)
return Logger::LOG_WARNING;
- else if(lowerStr == "error")
+ else if(str.caseCompare(ERROR_LEVEL, 0) == 0)
return Logger::LOG_ERROR;
- else if(lowerStr == "critical")
+ else if(str.caseCompare(CRITICAL_LEVEL, 0) == 0)
return Logger::LOG_CRITICAL;
else
throw Exception(Exception::INVALID_INPUT);
@@ -77,29 +82,29 @@ LogManager::~LogManager() {
bool LogManager::handleConfigEntry(const ConfigEntry &entry, bool handled) {
if(entry[0].getKey().matches("Log")) {
if(entry[0][0].matches("Console")) {
- if(entry[1].empty()) {
+ if(entry[1].isEmpty()) {
registerLogger(consoleLogger);
return true;
}
else if(entry[1].getKey().matches("Level")) {
- if(entry[2].empty()) {
+ if(entry[2].isEmpty()) {
try {
- if(boost::algorithm::to_lower_copy(static_cast<std::string>(entry[1][0])) == "remote")
+ if(entry[1][0].matches("remote"))
consoleLogger->setRemoteLevel(parseLevel(entry[1][1]));
else
consoleLogger->setLevel(parseLevel(entry[1][0]));
}
catch(Core::Exception e) {
- application->logf(Logger::LOG_WARNING, "Unknown log level '%s'.", entry[1][0].c_str());
+ application->logf(Logger::LOG_WARNING, "Unknown log level '%s'.", entry[1][0].extract().c_str());
}
return true;
}
}
}
- else if(entry[1].empty()) {
+ else if(entry[1].isEmpty()) {
if(!handled) {
- application->logf(Logger::LOG_WARNING, "Unknown logger '%s'.", entry[0][0].c_str());
+ application->logf(Logger::LOG_WARNING, "Unknown logger '%s'.", entry[0][0].extract().c_str());
return true;
}
}