2009-04-20 05:43:20 +02:00
/*
* ============================================================================
*
* Zombie : Reloaded
*
2009-06-12 05:51:26 +02:00
* File : log . inc
* Type : Core
* Description : Logging API .
*
* Copyright ( C ) 2009 Greyscale , Richard Helgeby
*
* This program is free software : you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation , either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program . If not , see < http :// www . gnu . org / licenses />.
2009-04-20 05:43:20 +02:00
*
* ============================================================================
*/
2009-06-01 23:29:26 +02:00
/*
* Note : See log . h . inc for header types and defines .
2009-04-20 05:43:20 +02:00
*/
2009-06-01 23:29:26 +02:00
2009-06-08 00:13:38 +02:00
LogInit ()
{
// Destroy existing handle to prevent memory leak.
if ( hLogModuleFilter != INVALID_HANDLE )
{
CloseHandle ( hLogModuleFilter );
}
// Initialize module filter array.
hLogModuleFilter = CreateArray ( 32 );
}
2009-06-01 23:29:26 +02:00
2009-04-20 05:43:20 +02:00
/**
2009-06-08 00:13:38 +02:00
* Convert module type to a string .
2009-06-01 23:29:26 +02:00
*
2009-06-08 00:13:38 +02:00
* @ param buffer Destination string buffer .
* @ param maxlen Size of destination buffer .
* @ param module Module type to convert .
* @ param shortName Optional . Use short name instead of human readable
* names . Default is false
* @ return Number of cells written .
2009-04-20 05:43:20 +02:00
*/
2009-06-08 00:13:38 +02:00
LogGetModuleNameString ( String : buffer [], maxlen , LogModules : module , bool : shortName = false )
2009-06-01 23:29:26 +02:00
{
switch ( module )
{
2009-06-07 17:51:37 +02:00
case LogModule_Account :
{
2009-06-08 00:13:38 +02:00
return shortName ? strcopy ( buffer , maxlen , " account " ) : strcopy ( buffer , maxlen , " Account " );
2009-06-07 17:51:37 +02:00
}
2009-06-01 23:29:26 +02:00
case LogModule_Antistick :
{
2009-06-08 00:13:38 +02:00
return shortName ? strcopy ( buffer , maxlen , " antistick " ) : strcopy ( buffer , maxlen , " Anti-Stick " );
2009-06-01 23:29:26 +02:00
}
case LogModule_Config :
{
2009-06-08 00:13:38 +02:00
return shortName ? strcopy ( buffer , maxlen , " config " ) : strcopy ( buffer , maxlen , " Config " );
2009-06-01 23:29:26 +02:00
}
case LogModule_Cvars :
{
2009-06-08 00:13:38 +02:00
return shortName ? strcopy ( buffer , maxlen , " cvars " ) : strcopy ( buffer , maxlen , " CVARs " );
2009-06-01 23:29:26 +02:00
}
case LogModule_Damage :
{
2009-06-08 00:13:38 +02:00
return shortName ? strcopy ( buffer , maxlen , " damage " ) : strcopy ( buffer , maxlen , " Damage " );
2009-06-01 23:29:26 +02:00
}
case LogModule_Downloads :
{
2009-06-08 00:13:38 +02:00
return shortName ? strcopy ( buffer , maxlen , " downloads " ) : strcopy ( buffer , maxlen , " Downloads " );
2009-06-01 23:29:26 +02:00
}
case LogModule_Hitgroups :
{
2009-06-08 00:13:38 +02:00
return shortName ? strcopy ( buffer , maxlen , " hitgroups " ) : strcopy ( buffer , maxlen , " Hit Groups " );
2009-06-01 23:29:26 +02:00
}
case LogModule_Infect :
{
2009-06-08 00:13:38 +02:00
return shortName ? strcopy ( buffer , maxlen , " infect " ) : strcopy ( buffer , maxlen , " Infect " );
2009-06-01 23:29:26 +02:00
}
case LogModule_Models :
{
2009-06-08 00:13:38 +02:00
return shortName ? strcopy ( buffer , maxlen , " models " ) : strcopy ( buffer , maxlen , " Models " );
2009-06-01 23:29:26 +02:00
}
case LogModule_Playerclasses :
{
2009-06-08 00:13:38 +02:00
return shortName ? strcopy ( buffer , maxlen , " playerclasses " ) : strcopy ( buffer , maxlen , " Player Classes " );
2009-06-01 23:29:26 +02:00
}
2009-06-08 06:05:50 +02:00
case LogModule_VEffects :
2009-06-01 23:29:26 +02:00
{
2009-06-08 06:05:50 +02:00
return shortName ? strcopy ( buffer , maxlen , " veffects " ) : strcopy ( buffer , maxlen , " Visual Effects " );
}
case LogModule_SEffects :
{
return shortName ? strcopy ( buffer , maxlen , " seffects " ) : strcopy ( buffer , maxlen , " Sound Effects " );
2009-06-01 23:29:26 +02:00
}
case LogModule_Tools :
{
2009-06-08 00:13:38 +02:00
return shortName ? strcopy ( buffer , maxlen , " tools " ) : strcopy ( buffer , maxlen , " Tools " );
2009-06-01 23:29:26 +02:00
}
2009-06-08 06:05:50 +02:00
case LogModule_Volfeatures :
2009-06-01 23:29:26 +02:00
{
2009-06-08 00:13:38 +02:00
return shortName ? strcopy ( buffer , maxlen , " volfeatures " ) : strcopy ( buffer , maxlen , " Volumetric Features " );
2009-06-01 23:29:26 +02:00
}
case LogModule_Weapons :
{
2009-06-08 00:13:38 +02:00
return shortName ? strcopy ( buffer , maxlen , " weapons " ) : strcopy ( buffer , maxlen , " Weapons " );
2009-06-01 23:29:26 +02:00
}
case LogModule_Weaponrestrict :
{
2009-06-08 00:13:38 +02:00
return shortName ? strcopy ( buffer , maxlen , " weaponrestrict " ) : strcopy ( buffer , maxlen , " Weapon Restrictions " );
2009-06-01 23:29:26 +02:00
}
}
// Module mismatch.
return 0 ;
}
2009-04-20 05:43:20 +02:00
2009-06-08 00:13:38 +02:00
/**
* Converts a string module name into a module type .
*
* @ param moduleName A string with the short module name . Case insensitive ,
* but not trimmed for white space .
* @ return The matcing module type or LogModules_Invalid if failed .
*/
LogModules : LogGetModule ( const String : moduleName [])
{
2009-06-08 06:05:50 +02:00
if ( StrEqual ( moduleName , " account " , false ))
2009-06-08 00:13:38 +02:00
{
return LogModule_Account ;
}
2009-06-08 06:05:50 +02:00
else if ( StrEqual ( moduleName , " antistick " , false ))
2009-06-08 00:13:38 +02:00
{
return LogModule_Antistick ;
}
2009-06-08 06:05:50 +02:00
else if ( StrEqual ( moduleName , " config " , false ))
2009-06-08 00:13:38 +02:00
{
return LogModule_Config ;
}
2009-06-08 06:05:50 +02:00
else if ( StrEqual ( moduleName , " cvars " , false ))
2009-06-08 00:13:38 +02:00
{
return LogModule_Cvars ;
}
2009-06-08 06:05:50 +02:00
else if ( StrEqual ( moduleName , " damage " , false ))
2009-06-08 00:13:38 +02:00
{
return LogModule_Damage ;
}
2009-06-08 06:05:50 +02:00
else if ( StrEqual ( moduleName , " downloads " , false ))
2009-06-08 00:13:38 +02:00
{
return LogModule_Downloads ;
}
2009-06-08 06:05:50 +02:00
else if ( StrEqual ( moduleName , " hitgroups " , false ))
2009-06-08 00:13:38 +02:00
{
return LogModule_Hitgroups ;
}
2009-06-08 06:05:50 +02:00
else if ( StrEqual ( moduleName , " infect " , false ))
2009-06-08 00:13:38 +02:00
{
return LogModule_Infect ;
}
2009-06-08 06:05:50 +02:00
else if ( StrEqual ( moduleName , " models " , false ))
2009-06-08 00:13:38 +02:00
{
return LogModule_Models ;
}
2009-06-08 06:05:50 +02:00
else if ( StrEqual ( moduleName , " playerclasses " , false ))
2009-06-08 00:13:38 +02:00
{
return LogModule_Playerclasses ;
}
2009-06-08 06:05:50 +02:00
else if ( StrEqual ( moduleName , " veffects " , false ))
{
return LogModule_VEffects ;
}
else if ( StrEqual ( moduleName , " seffects " , false ))
2009-06-08 00:13:38 +02:00
{
2009-06-08 06:05:50 +02:00
return LogModule_SEffects ;
2009-06-08 00:13:38 +02:00
}
2009-06-08 06:05:50 +02:00
else if ( StrEqual ( moduleName , " tools " , false ))
2009-06-08 00:13:38 +02:00
{
return LogModule_Tools ;
}
2009-06-08 06:05:50 +02:00
else if ( StrEqual ( moduleName , " volfeatures " , false ))
2009-06-08 00:13:38 +02:00
{
2009-06-08 06:05:50 +02:00
return LogModule_Volfeatures ;
2009-06-08 00:13:38 +02:00
}
2009-06-08 06:05:50 +02:00
else if ( StrEqual ( moduleName , " weapons " , false ))
2009-06-08 00:13:38 +02:00
{
return LogModule_Weapons ;
}
2009-06-08 06:05:50 +02:00
else if ( StrEqual ( moduleName , " weaponrestrict " , false ))
2009-06-08 00:13:38 +02:00
{
return LogModule_Weaponrestrict ;
}
// No match.
return LogModule_Invalid ;
}
2009-04-20 05:43:20 +02:00
/**
2009-06-01 23:29:26 +02:00
* Check if the specified log flag is set .
2009-04-20 05:43:20 +02:00
*
2009-06-01 23:29:26 +02:00
* @ param eventType The log flag to check .
* @ return True if set , false otherwise .
2009-04-20 05:43:20 +02:00
*/
2009-06-01 23:29:26 +02:00
bool : LogCheckFlag ( eventType )
2009-04-20 05:43:20 +02:00
{
2009-06-01 23:29:26 +02:00
// Check if eventType is set.
if ( GetConVarInt ( g_hCvarsList [ CVAR_LOG_FLAGS ]) & eventType )
2009-04-20 05:43:20 +02:00
{
2009-06-01 23:29:26 +02:00
return true ;
2009-04-20 05:43:20 +02:00
}
2009-06-01 23:29:26 +02:00
else
2009-04-20 05:43:20 +02:00
{
2009-06-01 23:29:26 +02:00
return false ;
2009-04-20 05:43:20 +02:00
}
2009-06-01 23:29:26 +02:00
}
/**
* Check if the specified module is enabled in the log module filter cache .
*
* @ param module Module to check .
* @ return True if enabled , false otherwise .
*/
bool : LogCheckModuleFilter ( LogModules : module )
{
if ( LogModuleFilterCache [ module ])
2009-05-14 09:32:01 +02:00
{
2009-06-01 23:29:26 +02:00
return true ;
2009-05-14 09:32:01 +02:00
}
2009-06-01 23:29:26 +02:00
else
2009-05-14 09:32:01 +02:00
{
2009-06-01 23:29:26 +02:00
return false ;
}
}
/**
* Print a formatted message to logs depending on log settings .
*
* @ param isConsole Optional . Specifies whether the log event came from
* client 0. Used in console commands , do not mix with
* regular log events . Default is false .
* @ param logType Optional . Log type and action . Default is
* LogType_Normal .
* @ param eventType Optional . A log flag describing What kind of log event
* it is . Default is LOG_CORE_EVENTS .
* @ param module Module the log event were executed in .
* @ param description Event type or function name . A short descriptive phrase
* to group together similar logs .
* @ param text Log message . Can be formatted .
* @ param ... Formatting parameters .
*/
LogEvent ( bool : isConsole = false , LogTypes : logType = LogType_Normal , eventType = LOG_CORE_EVENTS , LogModules : module , const String : description [], const String : text [], any :... )
{
// Only do filter and flag checks if the log type isn't a fatal error.
if ( logType != LogType_Fatal )
{
// Check if logging is disabled.
if ( ! GetConVarBool ( g_hCvarsList [ CVAR_LOG ]))
{
return ;
}
// Check if console is ignored.
if ( isConsole && GetConVarBool ( g_hCvarsList [ CVAR_LOG_IGNORE_CONSOLE ]))
{
return ;
}
// Check event type (log flag).
if ( ! LogCheckFlag ( eventType ))
{
return ;
}
// Check if module filtering is enabled.
if ( GetConVarBool ( g_hCvarsList [ CVAR_LOG_MODULE_FILTER ]))
{
// Check if the specified module is enabled.
if ( ! LogCheckModuleFilter ( module ))
{
return ;
}
}
2009-05-14 09:32:01 +02:00
}
// Format extra parameters into the log buffer.
decl String : logbuffer [ LOG_MAX_LENGTH_FILE ];
2009-06-05 05:58:48 +02:00
VFormat ( logbuffer , sizeof ( logbuffer ), text , 7 );
2009-05-14 09:32:01 +02:00
2009-06-01 23:29:26 +02:00
// Get human readable module name.
new String : modulename [ 64 ];
LogGetModuleNameString ( modulename , sizeof ( modulename ), module );
2009-05-14 09:32:01 +02:00
// Format
2009-06-01 23:29:26 +02:00
Format ( logbuffer , sizeof ( logbuffer ), " [%s] - [%s]: %s " , modulename , description , logbuffer );
2009-04-27 04:00:38 +02:00
// Format other parameters onto the log text.
2009-06-01 23:29:26 +02:00
switch ( logType )
2009-04-20 05:43:20 +02:00
{
2009-05-14 09:32:01 +02:00
// Log type is normal.
2009-06-01 23:29:26 +02:00
case LogType_Normal :
2009-04-20 05:43:20 +02:00
{
2009-05-14 09:32:01 +02:00
LogMessage ( logbuffer );
2009-04-20 05:43:20 +02:00
}
2009-04-27 04:00:38 +02:00
// Log type is error.
2009-06-01 23:29:26 +02:00
case LogType_Error :
2009-04-20 05:43:20 +02:00
{
2009-05-14 09:32:01 +02:00
LogError ( logbuffer );
2009-04-20 05:43:20 +02:00
}
2009-05-14 09:32:01 +02:00
// Log type is fatal error.
2009-06-01 23:29:26 +02:00
case LogType_Fatal :
2009-04-29 01:58:41 +02:00
{
2009-05-14 09:32:01 +02:00
SetFailState ( logbuffer );
2009-04-29 01:58:41 +02:00
}
2009-04-20 05:43:20 +02:00
}
2009-06-01 23:29:26 +02:00
// Note: The phrase "Literal text" is a blank phrase to pass any string we want into it.
// Check if printing log events to admins is enabled.
if ( GetConVarBool ( g_hCvarsList [ CVAR_LOG_PRINT_ADMINS ]))
2009-04-20 05:43:20 +02:00
{
// Print text to admins.
2009-06-01 23:29:26 +02:00
TranslationPrintToChatAll ( false , true , " Literal text " , logbuffer );
}
// Check if printing log events to public chat is enabled.
if ( GetConVarBool ( g_hCvarsList [ CVAR_LOG_PRINT_CHAT ]))
{
TranslationPrintToChatAll ( false , false , " Literal text " , logbuffer );
2009-04-20 05:43:20 +02:00
}
}
2009-06-07 17:51:37 +02:00
2009-06-08 00:13:38 +02:00
/**
* Adds a module to the module filter and updates the cache . If it already
* exist the command is ignored .
*
* @ param module The module to add .
* @ return True if added , false otherwise .
*/
bool : LogModuleFilterAdd ( LogModules : module )
{
decl String : modulename [ 64 ];
// Check if empty.
if ( strlen ( modulename ) == 0 )
{
return false ;
}
// Convert module name.
LogGetModuleNameString ( modulename , sizeof ( modulename ), module , true );
// Check if the module isn't already is listed.
2009-06-12 15:54:05 +02:00
if ( FindStringInArray ( hLogModuleFilter , modulename ) < 0 )
2009-06-08 00:13:38 +02:00
{
// Add module to filter.
PushArrayString ( hLogModuleFilter , modulename );
return true ;
}
return false ;
}
/**
* Removes a module to the module filter and updates the cache . If it doesn ' t
* exist the command is ignored .
*
* @ param module The module to remove .
* @ return True if removed , false otherwise .
*/
bool : LogModuleFilterRemove ( LogModules : module )
{
decl String : modulename [ 64 ];
new moduleindex ;
// Check if empty.
if ( strlen ( modulename ) == 0 )
{
return false ;
}
// Convert module name.
LogGetModuleNameString ( modulename , sizeof ( modulename ), module , true );
// Get the module index.
moduleindex = FindStringInArray ( hLogModuleFilter , modulename );
// Check if successful.
if ( moduleindex >= 0 )
{
// Remove module from filter.
RemoveFromArray ( hLogModuleFilter , moduleindex );
return true ;
}
return false ;
}
/**
* Update module filter cache .
*/
LogModuleFilterCacheUpdate ()
{
decl String : modulename [ 64 ];
new LogModules : moduletype ;
new modulecount ;
new filtersize ;
// Clear all entries in module cache.
modulecount = sizeof ( LogModuleFilterCache );
for ( new module = 1 ; module < modulecount ; module ++ )
{
LogModuleFilterCache [ LogModules : module ] = false ;
}
// Loop through the module array.
filtersize = GetArraySize ( hLogModuleFilter );
for ( new index = 0 ; index < filtersize ; index ++ )
{
// Get the module name.
GetArrayString ( hLogModuleFilter , index , modulename , sizeof ( modulename ));
// Convert to type.
moduletype = LogGetModule ( modulename );
// Validate type.
if ( moduletype != LogModule_Invalid )
{
// Set value in cache.
LogModuleFilterCache [ moduletype ] = true ;
}
}
}
2009-06-07 17:51:37 +02:00
/**
* Creates commands for logging module . Called when commands are created .
*/
LogOnCommandsCreate ()
{
RegConsoleCmd ( " zr_log_list " , Command_LogList , " List available logging flags and modules with their status values. " );
2009-06-08 00:13:38 +02:00
RegConsoleCmd ( " zr_log_add_module " , Command_LogAddModule , " Add one or more modules to the module filter. Usage: zr_log_add_module <module> [module] ... " );
RegConsoleCmd ( " zr_log_remove_module " , Command_LogRemoveModule , " Remove one or more modules from the module filter. Usage: zr_log_remove_module <module> [module] ... " );
2009-06-07 17:51:37 +02:00
}
/**
* Handles the zr_log_list command . Displays flags and module filter cache .
*
* @ param client The client that executed the command .
* @ param argc Number of arguments passed .
*/
public Action : Command_LogList ( client , argc )
{
decl String : buffer [ 2048 ];
decl String : linebuffer [ 96 ];
2009-06-08 00:13:38 +02:00
decl String : modulename [ 64 ];
decl String : modulenameshort [ 64 ];
2009-06-07 17:51:37 +02:00
2009-06-08 00:13:38 +02:00
new modulecount ;
// Strings to store translated phrases. Because formatting width settings
// doesn't work with "%t", but "%s".
decl String : phrasegenericflag [ 32 ];
decl String : phrasevalue [ 32 ];
decl String : phrasemodule [ 32 ];
decl String : phraseshortname [ 32 ];
// Quick initialize string buffer.
2009-06-07 17:51:37 +02:00
buffer [ 0 ] = 0 ;
// Set language.
SetGlobalTransTarget ( client );
2009-06-08 00:13:38 +02:00
// Get phrases.
Format ( phrasegenericflag , sizeof ( phrasegenericflag ), " %t " , " Log Generic Flag " );
Format ( phrasevalue , sizeof ( phrasevalue ), " %t " , " Log Value " );
Format ( phrasemodule , sizeof ( phrasemodule ), " %t " , " Log Module " );
Format ( phraseshortname , sizeof ( phraseshortname ), " %t " , " Log Module Short Name " );
2009-06-07 17:51:37 +02:00
// Log flags:
2009-06-08 00:13:38 +02:00
Format ( linebuffer , sizeof ( linebuffer ), " %-19s %-7s %t \n " , phrasegenericflag , phrasevalue , " Log Status " );
2009-06-07 17:51:37 +02:00
StrCat ( buffer , sizeof ( buffer ), linebuffer );
StrCat ( buffer , sizeof ( buffer ), " -------------------------------------------------------------------------------- \n " );
Format ( linebuffer , sizeof ( linebuffer ), " LOG_CORE_EVENTS 1 %t \n " , LogCheckFlag ( LOG_CORE_EVENTS ) ? " On " : " Off " );
StrCat ( buffer , sizeof ( buffer ), linebuffer );
Format ( linebuffer , sizeof ( linebuffer ), " LOG_GAME_EVENTS 2 %t \n " , LogCheckFlag ( LOG_GAME_EVENTS ) ? " On " : " Off " );
StrCat ( buffer , sizeof ( buffer ), linebuffer );
Format ( linebuffer , sizeof ( linebuffer ), " LOG_PLAYER_COMMANDS 4 %t \n " , LogCheckFlag ( LOG_PLAYER_COMMANDS ) ? " On " : " Off " );
StrCat ( buffer , sizeof ( buffer ), linebuffer );
Format ( linebuffer , sizeof ( linebuffer ), " LOG_DEBUG 8 %t \n " , LogCheckFlag ( LOG_DEBUG ) ? " On " : " Off " );
StrCat ( buffer , sizeof ( buffer ), linebuffer );
2009-06-08 00:13:38 +02:00
Format ( linebuffer , sizeof ( linebuffer ), " LOG_DEBUG_DETAIL 16 %t \n " , LogCheckFlag ( LOG_DEBUG_DETAIL ) ? " On " : " Off " );
2009-06-07 17:51:37 +02:00
StrCat ( buffer , sizeof ( buffer ), linebuffer );
2009-06-08 00:13:38 +02:00
ReplyToCommand ( client , buffer );
buffer [ 0 ] = 0 ;
2009-06-07 17:51:37 +02:00
// Module filtering status:
Format ( linebuffer , sizeof ( linebuffer ), " %t %t \n \n " , " Log Module Filtering " , GetConVarBool ( g_hCvarsList [ CVAR_LOG_MODULE_FILTER ]) ? " On " : " Off " );
StrCat ( buffer , sizeof ( buffer ), linebuffer );
2009-06-08 00:13:38 +02:00
Format ( linebuffer , sizeof ( linebuffer ), " %-23s %-19s %t \n " , phrasemodule , phraseshortname , " Log Status " );
2009-06-07 17:51:37 +02:00
StrCat ( buffer , sizeof ( buffer ), linebuffer );
2009-06-08 00:13:38 +02:00
StrCat ( buffer , sizeof ( buffer ), " -------------------------------------------------------------------------------- " );
2009-06-07 17:51:37 +02:00
2009-06-08 00:13:38 +02:00
ReplyToCommand ( client , buffer );
buffer [ 0 ] = 0 ;
2009-06-07 17:51:37 +02:00
2009-06-08 00:13:38 +02:00
// Module status:
modulecount = sizeof ( LogModuleFilterCache );
for ( new module = 1 ; module < modulecount ; module ++ )
{
LogGetModuleNameString ( modulename , sizeof ( modulename ), LogModules : module );
LogGetModuleNameString ( modulenameshort , sizeof ( modulenameshort ), LogModules : module , true );
Format ( linebuffer , sizeof ( linebuffer ), " %-23s %-19s %t " , modulename , modulenameshort , LogModuleFilterCache [ LogModules : module ] ? " On " : " Off " );
ReplyToCommand ( client , linebuffer );
}
2009-06-07 17:51:37 +02:00
2009-06-08 00:13:38 +02:00
return Plugin_Handled ;
}
/**
* Handles the zr_log_add_module command . Add one or modules to module filter .
*
* @ param client The client that executed the command .
* @ param argc Number of arguments passed .
*/
public Action : Command_LogAddModule ( client , argc )
{
decl String : buffer [ 256 ];
decl String : argument [ 32 ];
buffer [ 0 ] = 0 ;
2009-06-07 17:51:37 +02:00
2009-06-08 00:13:38 +02:00
new LogModules : logmodule ;
2009-06-07 17:51:37 +02:00
2009-06-08 00:13:38 +02:00
// Check if no arguments.
if ( argc < 1 )
{
// Display syntax info.
StrCat ( buffer , sizeof ( buffer ), " Add one or more modules to the module filter. Usage: zr_log_add_module <module> [module] ... \n " );
StrCat ( buffer , sizeof ( buffer ), " See zr_log_list to list available module names (short names). " );
ReplyToCommand ( client , buffer );
}
2009-06-07 17:51:37 +02:00
2009-06-08 00:13:38 +02:00
// Loop through each argument.
for ( new arg = 1 ; arg <= argc ; arg ++ )
{
// Get argument string.
GetCmdArg ( arg , argument , sizeof ( argument ));
// Convert to module type.
logmodule = LogGetModule ( argument );
// Check if invalid.
if ( logmodule == LogModule_Invalid )
{
ReplyToCommand ( client , " Invalid module name: \" %s \" " , argument );
// Skip to next argument.
continue ;
}
LogModuleFilterAdd ( logmodule );
ReplyToCommand ( client , " Added \" %s \" to module filter. " , argument );
}
2009-06-07 17:51:37 +02:00
2009-06-08 00:13:38 +02:00
// Update cache.
LogModuleFilterCacheUpdate ();
2009-06-07 17:51:37 +02:00
2009-06-08 00:13:38 +02:00
return Plugin_Handled ;
}
/**
* Handles the zr_log_add_module command . Remove one or modules to module filter .
*
* @ param client The client that executed the command .
* @ param argc Number of arguments passed .
*/
public Action : Command_LogRemoveModule ( client , argc )
{
decl String : buffer [ 256 ];
decl String : argument [ 32 ];
buffer [ 0 ] = 0 ;
2009-06-07 17:51:37 +02:00
2009-06-08 00:13:38 +02:00
new LogModules : logmodule ;
2009-06-07 17:51:37 +02:00
2009-06-08 00:13:38 +02:00
// Check if no arguments.
if ( argc < 1 )
{
// Display syntax info.
StrCat ( buffer , sizeof ( buffer ), " Add one or more modules to the module filter. Usage: zr_log_add_module <module> [module] ... \n " );
StrCat ( buffer , sizeof ( buffer ), " See zr_log_list to list available module names (short names). " );
ReplyToCommand ( client , buffer );
}
2009-06-07 17:51:37 +02:00
2009-06-08 00:13:38 +02:00
// Loop through each argument.
for ( new arg = 1 ; arg <= argc ; arg ++ )
{
// Get argument string.
GetCmdArg ( arg , argument , sizeof ( argument ));
// Convert to module type.
logmodule = LogGetModule ( argument );
// Check if invalid.
if ( logmodule == LogModule_Invalid )
{
ReplyToCommand ( client , " Invalid module name: \" %s \" " , argument );
// Skip to next argument.
continue ;
}
LogModuleFilterRemove ( logmodule );
ReplyToCommand ( client , " Removed \" %s \" from module filter. " , argument );
}
2009-06-07 17:51:37 +02:00
2009-06-08 00:13:38 +02:00
// Update cache.
LogModuleFilterCacheUpdate ();
2009-06-07 17:51:37 +02:00
return Plugin_Handled ;
}