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

Logging something without date/time


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Cader
Senior Member
Join Date: Mar 2007
Old 02-03-2010 , 08:42   Logging something without date/time
Reply With Quote #1

Hello,

I use log_to_file() function like everyone to log something to log file. But when you take a look at to my log file it really looks complicated because of those date/time values. Is it possible to log something without date and time of the action?
Cader is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-03-2010 , 13:29   Re: Logging something without date/time
Reply With Quote #2

You can manually write to a file. Or, you can just learn to ignore the timestamp.
__________________
fysiks is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 02-03-2010 , 13:51   Re: Logging something without date/time
Reply With Quote #3

Code:
log_to_file_notime( const szFilename[ ], const szLogFormat[ ], any:... ) {     static szLog[ 1024 ];     vformat( szLog, 1023, szLogFormat, 3 );         static szNewFilename[ 128 ];     if( contain( szFilename, "/" ) > 0 ) {         copy( szNewFilename, 127, szFilename );     } else {         formatex( szNewFilename, 127, "addons/amxmodx/logs/%s", szFilename );     }         static szPluginFile[ 64 ], szTrash[ 2 ];     get_plugin( -1, szPluginFile, 63, szTrash, 1, szTrash, 1, szTrash, 1, szTrash, 1 );         new iFile = fopen( szNewFilename, "a+" );     fprintf( iFile, "[%s] %s^n", szPluginFile, szLog );     fclose( iFile );         return 1; }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 02-04-2010 , 00:57   Re: Logging something without date/time
Reply With Quote #4

Rather than convert log_to_file, it would be better do use a custom function, like cache the file path in a global var so you only need to retrieve it once, and also, when you use a specific file, that file could also be plugin specific, so there is no need to add again the plugin name in the log.

PHP Code:
#include <amxmodx>

const MAX_LOG_LENGTH 256

new g_szLogFile[64// addons/amxmodx/logs/ = 20

public plugin_init()
{
    
get_localinfo("amxx_logs"g_szLogFilecharsmax(g_szLogFile))
    
add(g_szLogFilecharsmax(g_szLogFile), "/your_log_file.log")
}

LogToFile(const fmt[], any:...)
{
    new 
szLog[MAX_LOG_LENGTH]
    
vformat(szLogcharsmax(szLog), fmt2)

    new 
fp fopen(g_szLogFile"at")
    
fprintf(fp"%s^n"szLog)
    
fclose(fp)


Then you can do :

LogToFile("%s has killed %s", szKillerName, szVictimName)
__________________
- tired and retired -

- my plugins -
ConnorMcLeod 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 06:27.


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