summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-10-19 23:55:30 +0200
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-10-19 23:55:30 +0200
commit8629addec23239b667295c68ee3061ebc4ca918d (patch)
tree067f2969ea12053e5636dbb6035def59c32b01a2 /src/utils
parent77ea3d90114a7d6503d19e89ffaf2e548f63e420 (diff)
parent03ff7c110e536de1f8b239817e50cb07c492da6f (diff)
downloadmanaserv-8629addec23239b667295c68ee3061ebc4ca918d.tar.gz
manaserv-8629addec23239b667295c68ee3061ebc4ca918d.tar.bz2
manaserv-8629addec23239b667295c68ee3061ebc4ca918d.tar.xz
manaserv-8629addec23239b667295c68ee3061ebc4ca918d.zip
Merge branch 'master' of github.com:mana/manaserv
Conflicts: src/game-server/accountconnection.cpp
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 e5ceb9bc..8a070570 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 ba64b10b..65846be5 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; }
/**