Raised This Month: $ Target: $400
 0% 

How can i add logs to a plugin?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Boyka Abi
BANNED
Join Date: May 2012
Old 05-19-2012 , 14:41   How can i add logs to a plugin?
Reply With Quote #1

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.
Boyka Abi is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 05-19-2012 , 14:42   Re: How can i add logs to a plugin?
Reply With Quote #2

log_amx - to save log in the default amx logs for the specific date
log_to_file - to save log in a custom file
__________________

Last edited by <VeCo>; 05-19-2012 at 14:43.
<VeCo> is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 05-19-2012 , 14:59   Re: How can i add logs to a plugin?
Reply With Quote #3

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.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
Boyka Abi
BANNED
Join Date: May 2012
Old 05-19-2012 , 15:48   Re: How can i add logs to a plugin?
Reply With Quote #4

Thanks all.
Boyka Abi is offline
K1d0x
Senior Member
Join Date: Apr 2012
Location: Copenhagen, Denmark
Old 05-20-2012 , 02:06   Re: How can i add logs to a plugin?
Reply With Quote #5

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);
}

Last edited by K1d0x; 05-20-2012 at 02:10.
K1d0x is offline
Send a message via Yahoo to K1d0x Send a message via Skype™ to K1d0x
Boyka Abi
BANNED
Join Date: May 2012
Old 05-20-2012 , 05:50   Re: How can i add logs to a plugin?
Reply With Quote #6

I've already fixed it, but thanks.
Boyka Abi is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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