Improved logging system.

Made generic flags for log event types.
Made support for module filtering. Note: Manager for module filtering is not implemented. Don't enable filter when testing, otherwise nothing will be logged.
Updated all log events.
This commit is contained in:
richard
2009-06-01 23:29:26 +02:00
parent db866c6f43
commit 4ce30ac002
18 changed files with 317 additions and 141 deletions

View File

@ -26,14 +26,11 @@ enum CvarsList
{
Handle:CVAR_ENABLE,
Handle:CVAR_LOG,
Handle:CVAR_LOG_LOAD,
Handle:CVAR_LOG_CORE,
Handle:CVAR_LOG_FILTER_MODULES,
Handle:CVAR_LOG_FILTER_DESCRIPTION,
Handle:CVAR_LOG_FILTER_DEBUG,
Handle:CVAR_LOG_FLAGS,
Handle:CVAR_LOG_MODULE_FILTER,
Handle:CVAR_LOG_IGNORE_CONSOLE,
Handle:CVAR_LOG_PRINT_ADMINS,
Handle:CVAR_LOG_PRINT_CHAT,
Handle:CVAR_LOG_PRINT_CONSOLE,
Handle:CVAR_CONFIG_PATH_MODELS,
Handle:CVAR_CONFIG_PATH_DOWNLOADS,
Handle:CVAR_CONFIG_PATH_CLASSES,
@ -191,13 +188,12 @@ CvarsCreate()
// ===========================
// Log (core)
// ===========================
g_hCvarsList[CVAR_LOG] = CreateConVar("zr_log", "1", "Logs key actions performed by the plugin, including errors and debug.");
g_hCvarsList[CVAR_LOG_FILTER_MODULES] = CreateConVar("zr_log_filter_modules", "", "If any log module name is within this string, log will be suppressed. [Dependency: zr_log]");
g_hCvarsList[CVAR_LOG_FILTER_DESCRIPTION] = CreateConVar("zr_log_filter_description", "", "If any log description is within this string, log will be suppressed. [Dependency: zr_log]");
g_hCvarsList[CVAR_LOG_FILTER_DEBUG] = CreateConVar("zr_log_filter_debug", "1", "Supresses debug messages. [Dependency: zr_log]");
g_hCvarsList[CVAR_LOG_PRINT_ADMINS] = CreateConVar("zr_log_print_admins", "0", "Print all logs to currently connected admins. [Dependency: zr_log]");
g_hCvarsList[CVAR_LOG_PRINT_CHAT] = CreateConVar("zr_log_print_chat", "1", "Print log to admin's chat area. [Dependency: zr_log & zr_log_print_admins]");
g_hCvarsList[CVAR_LOG_PRINT_CONSOLE] = CreateConVar("zr_log_print_console", "1", "Print log to admin's console. [Dependency: zr_log & zr_log_print_admins]");
g_hCvarsList[CVAR_LOG] = CreateConVar("zr_log", "1", "Enable logging of events in the plugin. Fatal errors are logged independent on this setting.");
g_hCvarsList[CVAR_LOG_FLAGS] = CreateConVar("zr_log_flags", "3", "A bit field that specify what event types to log. See logging section (3.3) in manual for details.");
g_hCvarsList[CVAR_LOG_MODULE_FILTER] = CreateConVar("zr_log_module_filter", "0", "Enable module filtering. Only log events from listed modules will be logged.");
g_hCvarsList[CVAR_LOG_IGNORE_CONSOLE] = CreateConVar("zr_log_ignore_console", "1", "Don't log events triggered by console commands that are executed by the console itself, like commands in configs. Enable this command to avoid spamming logs with events like weapon restrictions.");
g_hCvarsList[CVAR_LOG_PRINT_ADMINS] = CreateConVar("zr_log_print_admins", "0", "Print log events to admin chat in addition to the log file.");
g_hCvarsList[CVAR_LOG_PRINT_CHAT] = CreateConVar("zr_log_print_chat", "0", "Print log events to public chat in addition to the log file.");
// ===========================
@ -531,7 +527,7 @@ public CvarsHookLocked(Handle:cvar, const String:oldvalue[], const String:newval
SetConVarInt(g_hAutoTeamBalance, CVARS_AUTOTEAMBALANCE_LOCKED);
// If log flag check fails, then don't log.
LogPrintToLog(_, "Cvars", "Cvar Locked", "Cvar \"mp_autoteambalance\" was reverted back to \"CVARS_AUTOTEAMBALANCE_LOCKED\".");
LogEvent(false, LogType_Normal, LOG_CORE_EVENTS, LogModule_Cvars, "Cvar Locked", "Cvar \"mp_autoteambalance\" was reverted back to \"CVARS_AUTOTEAMBALANCE_LOCKED\".");
}
// If cvar is mp_limitteams, then continue.
else if (cvar == g_hLimitTeams)
@ -546,7 +542,7 @@ public CvarsHookLocked(Handle:cvar, const String:oldvalue[], const String:newval
SetConVarInt(g_hLimitTeams, CVARS_LIMITTEAMS_LOCKED);
// If log flag check fails, then don't log.
LogPrintToLog(_, "Cvars", "Cvar Locked", "Cvar \"mp_limitteams\" was reverted back to \"CVARS_LIMITTEAMS_LOCKED\".");
LogEvent(false, LogType_Normal, LOG_CORE_EVENTS, LogModule_Cvars, "Cvar Locked", "Cvar \"mp_limitteams\" was reverted back to \"CVARS_LIMITTEAMS_LOCKED\".");
}
}
@ -574,5 +570,5 @@ public CvarsHookRestartGame(Handle:cvar, const String:oldvalue[], const String:n
RoundEndTerminateRound(delay);
// If log flag check fails, then don't log.
LogPrintToLog(_, "Cvars", "Restart Game", "\"mp_restartgame\" was caught and blocked, commencing round.");
LogEvent(false, LogType_Normal, LOG_CORE_EVENTS, LogModule_Cvars, "Restart Game", "\"mp_restartgame\" was caught and blocked, commencing round.");
}