diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/account-server/main-account.cpp | 19 | ||||
-rw-r--r-- | src/game-server/main-game.cpp | 19 | ||||
-rw-r--r-- | src/utils/logger.cpp | 17 | ||||
-rw-r--r-- | src/utils/logger.h | 4 |
4 files changed, 21 insertions, 38 deletions
diff --git a/src/account-server/main-account.cpp b/src/account-server/main-account.cpp index 5520fb8..01ec0ce 100644 --- a/src/account-server/main-account.cpp +++ b/src/account-server/main-account.cpp @@ -141,14 +141,7 @@ static void initialize() // Initialize PhysicsFS PHYSFS_init(""); - // Initialize the logger. - Logger::setLogFile(logFile, true); - - // Write the messages to both the screen and the log file. - Logger::setTeeMode( - Configuration::getBoolValue("log_accountToStandardOutput", - true)); - LOG_INFO("Using log file: " << logFile); + Logger::initialize(logFile); // Indicate in which file the statistics are put. statisticsFile = Configuration::getValue("log_statisticsFile", @@ -156,16 +149,6 @@ static void initialize() LOG_INFO("Using statistics file: " << statisticsFile); - // Set up the options related to log rotation. - Logger::enableLogRotation(Configuration::getBoolValue("log_enableRotation", - false)); - - Logger::setMaxLogfileSize(Configuration::getValue("log_maxFileSize", - 1024)); - - Logger::setSwitchLogEachDay(Configuration::getBoolValue("log_perDay", - false)); - ResourceManager::initialize(); // Open database diff --git a/src/game-server/main-game.cpp b/src/game-server/main-game.cpp index 9d96a6a..a9a6652 100644 --- a/src/game-server/main-game.cpp +++ b/src/game-server/main-game.cpp @@ -164,24 +164,7 @@ static void initializeServer() // Initialize PhysicsFS PHYSFS_init(""); - // Initialize the logger. - Logger::setLogFile(logFile, true); - - // Write the messages to both the screen and the log file. - Logger::setTeeMode(Configuration::getBoolValue("log_gameToStandardOutput", - true)); - - LOG_INFO("Using log file: " << logFile); - - // Set up the options related to log rotation. - Logger::enableLogRotation(Configuration::getBoolValue("log_enableRotation", - false)); - - Logger::setMaxLogfileSize(Configuration::getValue("log_maxFileSize", - 1024)); - - Logger::setSwitchLogEachDay(Configuration::getBoolValue("log_perDay", - false)); + Logger::initialize(logFile); // --- Initialize the managers // Initialize the slang's and double quotes filter. 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; } /** |