diff options
author | Spp <spp@jorge.gr> | 2012-08-03 14:20:18 +0200 |
---|---|---|
committer | Spp <spp@jorge.gr> | 2012-08-03 14:20:18 +0200 |
commit | 55ce180f2867700b28921d99f9a0cb9c83330c91 (patch) | |
tree | c563db507cce44b680996d42148185cb1512188c /src/server/worldserver/Main.cpp | |
parent | f85908869986eab0b645f0a697028bcceba7778c (diff) |
Core/Logging: Add Asyncronous logging with Loggers ("What to log") and Appenders ("Where to log") system. Will allow to select to full log some parts of core while others are not even logged.
- Logging System is asyncronous to improve performance.
- Each msg and Logger has a Log Type and Log Level assigned. Each msg is assigned the Logger of same Log Type or "root" Logger is selected if there is no Logger configured for the given Log Type
- Loggers have a list of Appenders to send the msg to. The Msg in the Logger is not sent to Appenders if the msg LogLevel is lower than Logger LogLevel.
- There are three (at the moment) types of Appenders: Console, File or DB (this is WIP, not working ATM). Msg is not written to the resource if msg LogLevel is lower than Appender LogLevel.
- Appender and Console Log levels can be changed while server is active with command '.set loglevel (a/l) name level'
Explanation of use with Sample config:
Appender.Console.Type=1 (1 = Console)
Appender.Console.Level=2 (2 = Debug)
Appender.Server.Type=2 (2 = File)
Appender.Server.Level=3 (3 = Info)
Appender.Server.File=Server.log
Appender.SQL.Type=2 (2 = File)
Appender.SQL.Level=1 (1 = Trace)
Appender.SQL.File=sql.log
Appenders=Console Server (NOTE: SQL has not been included here... that will make core ignore the config for "SQL" as it's not in this list)
Logger.root.Type=0 (0 = Default - if it's not created by config, server will create it with LogLevel = DISABLED)
Logger.root.Level=5 (5 = Error)
Logger.root.Appenders=Console
Logger.SQL.Type=26 (26 = SQL)
Logger.SQL.Level=3 (2 = Debug)
Logger.SQL.Appenders=Console Server SQL
Logger.SomeRandomName.Type=24 (24 = Guild)
Logger.SomeRandomName.Level=5 (5 = Error)
Loggers=root SQL SomeRandomName
* At loading Appender SQL will be ignored, as it's not present on "Appenders"
* sLog->outDebug(LOG_FILTER_GUILD, "Some log msg related to Guilds")
- Msg is sent to Logger of Type LOG_FILTER_GUILD (24). Logger with name SomeRandomName is found but it's LogLevel = 5 and Msg LogLevel=2... Msg is not logged
* sLog->outError(LOG_FILTER_GUILD, "Some error log msg related to Guilds")
- Msg is sent to Logger of Type LOG_FILTER_GUILD (24). Logger with name SomeRandomeName is found with proper LogLevel but Logger does not have any Appenders assigned to that logger... Msg is not logged
* sLog->outDebug(LOG_FILTER_SQL, "Some msg related to SQLs")
- Msg is sent to Logger SQL (matches type), as it matches LogLevel the msg is sent to Appenders Console, Server and SQL
- Appender Console has lower Log Level: Msg is logged to Console
- Appender Server has higher Log Level: Msg is not logged to file
- Appender SQL has lower Log Level: Msg is logged to file sql.log
* sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Some msg related to Battelgrounds")
- Msg is sent to Logger root (Type 0) as no Logger was found with Type LOG_FILTER_BATTLEGROUND (13). As Logger has higher LogLevel msg is not sent to any appender
* sLog->outError(LOG_FILTER_BATTLEGROUND, "Some error msg related to Battelgrounds")
- Msg is sent to Logger root (Type 0) as no Logger was found with Type LOG_FILTER_BATTLEGROUND (13). Msg has lower LogLevel and is sent to Appender Console
- Appender Console has lower LogLevel: Msg is logged to Console
Diffstat (limited to 'src/server/worldserver/Main.cpp')
-rwxr-xr-x | src/server/worldserver/Main.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/server/worldserver/Main.cpp b/src/server/worldserver/Main.cpp index 04820f59355..862ed28f2d3 100755 --- a/src/server/worldserver/Main.cpp +++ b/src/server/worldserver/Main.cpp @@ -58,7 +58,7 @@ uint32 realmID; ///< Id of the realm /// Print out the usage string for this program on the console. void usage(const char *prog) { - sLog->outString("Usage: \n %s [<options>]\n" + sLog->outInfo(LOG_FILTER_WORLDSERVER, "Usage: \n %s [<options>]\n" " -c config_file use config_file as configuration file\n\r" #ifdef _WIN32 " Running as service functions:\n\r" @@ -81,7 +81,7 @@ extern int main(int argc, char **argv) { if (++c >= argc) { - sLog->outError("Runtime-Error: -c option requires an input argument"); + sLog->outError(LOG_FILTER_WORLDSERVER, "Runtime-Error: -c option requires an input argument"); usage(argv[0]); return 1; } @@ -97,25 +97,25 @@ extern int main(int argc, char **argv) { if (++c >= argc) { - sLog->outError("Runtime-Error: -s option requires an input argument"); + sLog->outError(LOG_FILTER_WORLDSERVER, "Runtime-Error: -s option requires an input argument"); usage(argv[0]); return 1; } if (strcmp(argv[c], "install") == 0) { if (WinServiceInstall()) - sLog->outString("Installing service"); + sLog->outInfo(LOG_FILTER_WORLDSERVER, "Installing service"); return 1; } else if (strcmp(argv[c], "uninstall") == 0) { if (WinServiceUninstall()) - sLog->outString("Uninstalling service"); + sLog->outInfo(LOG_FILTER_WORLDSERVER, "Uninstalling service"); return 1; } else { - sLog->outError("Runtime-Error: unsupported option %s", argv[c]); + sLog->outError(LOG_FILTER_WORLDSERVER, "Runtime-Error: unsupported option %s", argv[c]); usage(argv[0]); return 1; } @@ -131,14 +131,14 @@ extern int main(int argc, char **argv) if (!ConfigMgr::Load(cfg_file)) { - sLog->outError("Invalid or missing configuration file : %s", cfg_file); - sLog->outError("Verify that the file exists and has \'[worldserver]' written in the top of the file!"); + sLog->outError(LOG_FILTER_WORLDSERVER, "Invalid or missing configuration file : %s", cfg_file); + sLog->outError(LOG_FILTER_WORLDSERVER, "Verify that the file exists and has \'[worldserver]' written in the top of the file!"); return 1; } - sLog->outString("Using configuration file %s.", cfg_file); + sLog->outInfo(LOG_FILTER_WORLDSERVER, "Using configuration file %s.", cfg_file); - sLog->outString("Using SSL version: %s (library: %s)", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION)); - sLog->outString("Using ACE version: %s", ACE_VERSION); + sLog->outInfo(LOG_FILTER_WORLDSERVER, "Using SSL version: %s (library: %s)", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION)); + sLog->outInfo(LOG_FILTER_WORLDSERVER, "Using ACE version: %s", ACE_VERSION); ///- and run the 'Master' /// \todo Why do we need this 'Master'? Can't all of this be in the Main as for Realmd? |