diff options
author | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2010-09-07 23:14:34 +0200 |
---|---|---|
committer | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2010-09-07 23:14:34 +0200 |
commit | de803e103f5317856d4eadf15661ef7516cfc72a (patch) | |
tree | bd9aeacc7699ae6cf861aeeef8fb37a2a45dd92d /src/account-server | |
parent | 3d7347011cc6b33ad2c2ceb939f27200a2cae4a6 (diff) | |
download | manaserv-de803e103f5317856d4eadf15661ef7516cfc72a.tar.gz manaserv-de803e103f5317856d4eadf15661ef7516cfc72a.tar.bz2 manaserv-de803e103f5317856d4eadf15661ef7516cfc72a.tar.xz manaserv-de803e103f5317856d4eadf15661ef7516cfc72a.zip |
Added config options to set stats and log files and paths.
Also turned the absence of an inter-server password into a fatal
error while documenting it in the manaserv.xml example file.
Reviewed-by: Jaxad0127.
Diffstat (limited to 'src/account-server')
-rw-r--r-- | src/account-server/main-account.cpp | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/src/account-server/main-account.cpp b/src/account-server/main-account.cpp index 33df1cb7..733369d7 100644 --- a/src/account-server/main-account.cpp +++ b/src/account-server/main-account.cpp @@ -60,6 +60,8 @@ static bool running = true; /**< Determines if server keeps running */ utils::StringFilter *stringFilter; /**< Slang's Filter */ +static std::string statisticsFile = std::string(); + /** Database handler. */ Storage *storage; @@ -112,7 +114,10 @@ static void initializeConfiguration(std::string configPath = std::string()) // Check inter-server password. if (Configuration::getValue("net_password", "") == "") - LOG_WARN("SECURITY WARNING: 'net_password' not set!"); + { + LOG_FATAL("SECURITY WARNING: 'net_password' not set!"); + exit(3); + } } /** @@ -133,30 +138,36 @@ static void initialize() // Set enet to quit on exit. atexit(enet_deinitialize); -#if defined LOG_FILE - std::string logPath = LOG_FILE; -#else - std::string logPath = DEFAULT_LOG_FILE; -#endif // defined LOG_FILE + std::string logFile = Configuration::getValue("log_accountServerFile", + DEFAULT_LOG_FILE); // Initialize PhysicsFS PHYSFS_init(""); // Initialize the logger. - Logger::setLogFile(logPath); + Logger::setLogFile(logFile); // write the messages to both the screen and the log file. Logger::setTeeMode(true); - LOG_INFO("Using log file: " << logPath); + LOG_INFO("Using log file: " << logFile); + + // Indicate in which file the statistics are put. + statisticsFile = Configuration::getValue("log_statisticsFile", + DEFAULT_STATS_FILE); + + LOG_INFO("Using statistics file: " << statisticsFile); ResourceManager::initialize(); // Open database - try { + try + { storage = new Storage; storage->open(); - } catch (std::string &error) { + } + catch (std::string &error) + { LOG_FATAL("Error opening the database: " << error); exit(1); } @@ -174,7 +185,8 @@ static void initialize() chatHandler = new ChatHandler; // --- Initialize enet. - if (enet_initialize() != 0) { + if (enet_initialize() != 0) + { LOG_FATAL("An error occurred while initializing ENet"); exit(2); } @@ -222,13 +234,7 @@ static void deinitializeServer() */ static void dumpStatistics() { -#if defined STATS_FILE - std::string path = STATS_FILE; -#else - std::string path = DEFAULT_STATS_FILE; -#endif - - std::ofstream os(path.c_str()); + std::ofstream os(statisticsFile.c_str()); os << "<statistics>\n"; GameServerHandler::dumpStatistics(os); os << "</statistics>\n"; |