Logging for Developers
The main log function used everywhere in the code funnels through Out or Log.Out and is macroed to simply Log

Example

1
void Out(Logs::DebugLevel debug_level, uint16 log_category, std::string message, ...);
2
3
Usage:
4
5
Log(Logs::General, Logs::Zone_Server, "Loading server configuration...");
Copied!
The macro is necessary because we check for whether the category is enabled or not everywhere we call a log function, this was to save massive overhead of pushing/popping strings on the call stack through a function name only to return immediately out.
1
#define Log(debug_level, log_category, message, ...) do {\
2
if (LogSys.log_settings[log_category].is_category_enabled == 1)\
3
LogSys.Out(debug_level, log_category, message, ##__VA_ARGS__);\
4
} while (0)
Copied!

Adding New Categories

    For development purposes, you may want to add a new category, this is very simple to do
    An example of a category being added can be seen at this commit: How to add a category
    An entry needs to be added to the enum and the constant to add a new category - and a database update is not required for it to be functional, but it is required for folks to be able to set the default settings in their server

Adding Default Values

In eqemu_logsys.cpp you can set default values for the log system initialization routine
1
void EQEmuLogSys::LoadLogSettingsDefaults()
2
{
3
/* Get Executable platform currently running this code (Zone/World/etc) */
4
log_platform = GetExecutablePlatformInt();
5
6
/* Zero out Array */
7
memset(log_settings, 0, sizeof(LogSettings) * Logs::LogCategory::MaxCategoryID);
8
9
/* Set Defaults */
10
log_settings[Logs::World_Server].log_to_console = Logs::General;
11
log_settings[Logs::Zone_Server].log_to_console = Logs::General;
12
log_settings[Logs::QS_Server].log_to_console = Logs::General;
13
log_settings[Logs::UCS_Server].log_to_console = Logs::General;
14
log_settings[Logs::Crash].log_to_console = Logs::General;
15
log_settings[Logs::MySQLError].log_to_console = Logs::General;
16
log_settings[Logs::Login_Server].log_to_console = Logs::General;
17
log_settings[Logs::Headless_Client].log_to_console = Logs::General;
18
19
/* Set Category enabled status on defaults */
20
log_settings[Logs::World_Server].is_category_enabled = 1;
21
log_settings[Logs::Zone_Server].is_category_enabled = 1;
22
log_settings[Logs::QS_Server].is_category_enabled = 1;
23
log_settings[Logs::UCS_Server].is_category_enabled = 1;
24
log_settings[Logs::Crash].is_category_enabled = 1;
25
log_settings[Logs::MySQLError].is_category_enabled = 1;
26
log_settings[Logs::Login_Server].is_category_enabled = 1;
27
...
Copied!

Default Category Colors

Color settings for GMSay and console respectively can be managed in eqemu_logsys.cpp
Last modified 2yr ago