AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How can i add logs to a plugin? (https://forums.alliedmods.net/showthread.php?t=185612)

Boyka Abi 05-19-2012 14:41

How can i add logs to a plugin?
 
Hello people, title says all. I want to add some logs to a plugin, for example if an admin abuses something I can watch it back in my logs.

<VeCo> 05-19-2012 14:42

Re: How can i add logs to a plugin?
 
log_amx - to save log in the default amx logs for the specific date
log_to_file - to save log in a custom file

Liverwiz 05-19-2012 14:59

Re: How can i add logs to a plugin?
 
Most admin events are automatically logged in the amx logs. including amxmodmenu admins and amx_super admins. UAIO might even be logged too....but i'm not sure.
If you're writing your own admin event use log_to_file so you can stick it in a specified log for your own plugin.

Boyka Abi 05-19-2012 15:48

Re: How can i add logs to a plugin?
 
Thanks all.

K1d0x 05-20-2012 02:06

Re: How can i add logs to a plugin?
 
1
Quote:

log_amx("Plugin test")
2
Quote:

#define FILE "FILE_NAME.log"

public log_test() {
log_to_file(FILE, "Plugin test")
}
3
Quote:

#define HISTORY_IN_ONE_FILE // if you want to create logs only in one file add // before define

public log_test() {
Log("Plugin test")
}

Log(const message_fmt[], any:...)
{
static message[256];
vformat(message, sizeof(message) - 1, message_fmt, 2);

static filename[96];
#if defined HISTORY_IN_ONE_FILE
if( !filename[0] )
{
get_basedir(filename, sizeof(filename) - 1);
add(filename, sizeof(filename) - 1, "/logs/File_name.log");
}
#else
static dir[64];
if( !dir[0] )
{
get_basedir(dir, sizeof(dir) - 1);
add(dir, sizeof(dir) - 1, "/logs");
}

format_time(filename, sizeof(filename) - 1, "%m%d%Y");
format(filename, sizeof(filename) - 1, "%s/File_name_%s.log", dir, filename);
#endif

log_amx("%s", message);
log_to_file(filename, "%s", message);
}

Boyka Abi 05-20-2012 05:50

Re: How can i add logs to a plugin?
 
I've already fixed it, but thanks.


All times are GMT -4. The time now is 00:29.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.