summaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2011-10-18 21:26:11 +0200
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2011-10-19 22:35:33 +0200
commit4d229c71983aa7c808ed97970c7d697cfbb70c49 (patch)
tree456743c48eef0efdbdf98eebc9b7efe39a7140b6 /src/utils
parent9c02241c2c714e94f8af413030ed55a64179f06b (diff)
downloadmanaserv-4d229c71983aa7c808ed97970c7d697cfbb70c49.tar.gz
manaserv-4d229c71983aa7c808ed97970c7d697cfbb70c49.tar.xz
manaserv-4d229c71983aa7c808ed97970c7d697cfbb70c49.zip
Have one place where the Logger is initialized
log_accountToStandardOutput and log_gameToStandardOutput have been merged together as log_toStandardOutput. Reviewed-by: Yohann Ferreira
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/logger.cpp17
-rw-r--r--src/utils/logger.h4
2 files changed, 19 insertions, 2 deletions
diff --git a/src/utils/logger.cpp b/src/utils/logger.cpp
index e5ceb9b..8a07057 100644
--- a/src/utils/logger.cpp
+++ b/src/utils/logger.cpp
@@ -20,6 +20,7 @@
*/
#include "logger.h"
+#include "common/configuration.h"
#include "common/resourcemanager.h"
#include "utils/string.h"
#include "utils/time.h"
@@ -63,7 +64,7 @@ static std::string mOldDate;
*
* @return whether the day has changed.
*/
-bool getDayChanged()
+static bool getDayChanged()
{
std::string dayDate = getCurrentDate();
@@ -78,6 +79,20 @@ bool getDayChanged()
return false;
}
+void Logger::initialize(const std::string &logFile)
+{
+ setLogFile(logFile, true);
+
+ // Write the messages to both the screen and the log file.
+ setTeeMode(Configuration::getBoolValue("log_toStandardOutput", true));
+ LOG_INFO("Using log file: " << logFile);
+
+ // Set up the options related to log rotation.
+ setLogRotation(Configuration::getBoolValue("log_enableRotation", false));
+ setMaxLogfileSize(Configuration::getValue("log_maxFileSize", 1024));
+ setSwitchLogEachDay(Configuration::getBoolValue("log_perDay", false));
+}
+
void Logger::output(std::ostream &os, const std::string &msg, const char *prefix)
{
if (mHasTimestamp)
diff --git a/src/utils/logger.h b/src/utils/logger.h
index ba64b10..65846be 100644
--- a/src/utils/logger.h
+++ b/src/utils/logger.h
@@ -82,6 +82,8 @@ class Logger
Debug
};
+ static void initialize(const std::string &logFile);
+
/**
* Sets the log file.
*
@@ -127,7 +129,7 @@ class Logger
*
* @param enable Set to true to enable logrotation.
*/
- static void enableLogRotation(bool enable = true)
+ static void setLogRotation(bool enable)
{ mLogRotation = enable; }
/**