Raised This Month: $51 Target: $400
 12% 

Connect Logs


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
lantimilan
Senior Member
Join Date: May 2016
Old 06-04-2020 , 02:34   Connect Logs
Reply With Quote #1

Hello i have one plugin for log in day but all log save in one file i like to make log for everyday can help me somebody :

PHP Code:
#include <amxmodx>

#define LOG_CONNECTING
//#define LOG_DISCONNECTING

#define LOG_FILE "addons/amxmodx/logs/Connect.log"

public plugin_init()
    
register_plugin("Connect Logs""1.0""OciXCrom")


#if defined LOG_CONNECTING
public client_putinserver(id)
    
log_connection(idtrue)
#endif

#if defined LOG_DISCONNECTING
public client_disconnect(id)
    
log_connection(idfalse)
#endif

log_connection(const id, const bool:bConnect)
{
    new 
szName[32], szAuthId[35], szIP[22]
    
get_user_name(idszNamecharsmax(szName))
    
get_user_authid(idszAuthIdcharsmax(szAuthId))
    
get_user_ip(idszIPcharsmax(szIP))    
    
log_to_file(LOG_FILE"%s: %s [%s | %s]"bConnect "CONNECT" "DISCONNECT"szNameszIPszAuthId)

lantimilan is offline
Send a message via MSN to lantimilan
alferd
Veteran Member
Join Date: Dec 2019
Location: Iran is Always Eternal
Old 06-04-2020 , 14:32   Re: Connect Logs
Reply With Quote #2

Quote:
Originally Posted by lantimilan View Post
Hello i have one plugin for log in day but all log save in one file i like to make log for everyday can help me somebody :

PHP Code:
#include <amxmodx>

#define LOG_CONNECTING
//#define LOG_DISCONNECTING

#define LOG_FILE "addons/amxmodx/logs/Connect.log"

public plugin_init()
    
register_plugin("Connect Logs""1.0""OciXCrom")


#if defined LOG_CONNECTING
public client_putinserver(id)
    
log_connection(idtrue)
#endif

#if defined LOG_DISCONNECTING
public client_disconnect(id)
    
log_connection(idfalse)
#endif

log_connection(const id, const bool:bConnect)
{
    new 
szName[32], szAuthId[35], szIP[22]
    
get_user_name(idszNamecharsmax(szName))
    
get_user_authid(idszAuthIdcharsmax(szAuthId))
    
get_user_ip(idszIPcharsmax(szIP))    
    
log_to_file(LOG_FILE"%s: %s [%s | %s]"bConnect "CONNECT" "DISCONNECT"szNameszIPszAuthId)

Code:
#include <amxmodx> #define LOG_CONNECTING //#define LOG_DISCONNECTING #define LOG_FILE "addons/amxmodx/logs/Connect.log" public plugin_init()     register_plugin("Connect Logs", "1.0", "OciXCrom") #if defined LOG_CONNECTING public client_putinserver(id)     log_connection(id, true) #endif #if defined LOG_DISCONNECTING public client_disconnect(id)     log_connection(id, false) #endif log_connection(const id, const bool:bConnect) {     new szTime[64]     get_time( "%m/%d/%Y", szTime, charsmax(szTime) )             new szName[32], szAuthId[35], szIP[22]     get_user_name(id, szName, charsmax(szName))     get_user_authid(id, szAuthId, charsmax(szAuthId))     get_user_ip(id, szIP, charsmax(szIP))        log_to_file(LOG_FILE, "%s | %s: %s [%s | %s]", szTime, bConnect ? "CONNECT" : "DISCONNECT", szName, szIP, szAuthId) }
alferd is offline
+ARUKARI-
AlliedModders Donor
Join Date: Jul 2004
Location: Japan
Old 06-08-2020 , 03:11   Re: Connect Logs
Reply With Quote #3

Try this if you request one file a day.
PHP Code:
// Change this.
#define LOG_FILE "addons/amxmodx/logs/Connect-%s.log"


log_connection(const id, const bool:bConnect)
{
    new 
szName[32], szAuthId[35], szIP[22]
    
get_user_name(idszNamecharsmax(szName))
    
get_user_authid(idszAuthIdcharsmax(szAuthId))
    
get_user_ip(idszIPcharsmax(szIP))

    
// Add logic.
    
new datetime[7], logfile[128];
    
get_time("%Y%M%D"datetimecharsmax(datetime));
    
formatex(logfilecharsmax(logfile), LOG_FILEdatetime);

    
// change LOG_FILE to logfile.
    
log_to_file(logfile"%s: %s [%s | %s]"bConnect "CONNECT" "DISCONNECT"szNameszIPszAuthId)

__________________
GitHub
SteamWishlist

六四天安門事件

Last edited by +ARUKARI-; 06-08-2020 at 04:15.
+ARUKARI- is offline
alferd
Veteran Member
Join Date: Dec 2019
Location: Iran is Always Eternal
Old 06-08-2020 , 04:12   Re: Connect Logs
Reply With Quote #4

Quote:
Originally Posted by +ARUKARI- View Post
Try this if you request one file a day.
PHP Code:
// Change this.
#define LOG_FILE "addons/amxmodx/logs/Connect-%s.log"


log_connection(const id, const bool:bConnect)
{
    new 
szName[32], szAuthId[35], szIP[22]
    
get_user_name(idszNamecharsmax(szName))
    
get_user_authid(idszAuthIdcharsmax(szAuthId))
    
get_user_ip(idszIPcharsmax(szIP))

    
// Add logic.
    
new datetime[7], logfile[128];
    
get_time("%Y%M"datetimecharsmax(datetime));
    
formatex(logfilecharsmax(logfile), LOG_FILEdatetime);

    
// change LOG_FILE to logfile.
    
log_to_file(logfile"%s: %s [%s | %s]"bConnect "CONNECT" "DISCONNECT"szNameszIPszAuthId)

Does the result look like the example below?

Code:
Connect-6/8.log
Connect-6/9.log
Connect-6/10.log
alferd is offline
+ARUKARI-
AlliedModders Donor
Join Date: Jul 2004
Location: Japan
Old 06-08-2020 , 05:02   Re: Connect Logs
Reply With Quote #5

Code:
Connect-20200607.log
__________________
GitHub
SteamWishlist

六四天安門事件
+ARUKARI- 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 12:11.


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