[Include] rLogs | Server logs
#10

Quote:
Originally Posted by ******
Посмотреть сообщение
You know you can just do "printf" and the text will be formatted and logged, right?
Honestly no.
If I do that what the file name will be?

With this you can set the file name and you can add a "Comment"
Look at the source code:
pawn Код:
#include <  a_samp  >
#include < YSI\y_va >

#if defined _ServerLogs_included
    #endinput
#endif

#define _ServerLogs_included

#define LogExist fexist

stock WriteInLog( const Log_File[ ], Log_Com[ ], Log_Par[ ], va_args< > )
{
    if( !LogExist( Log_File ) )
    {
        new
            File:File_Rk = fopen( Log_File, io_write )
        ;
        fclose( File_Rk );
    }
   
    new
        rGz_iSTRG[ 300 ],   rYear,      rHour,
        rQz_iSTRG[ 100 ],   rMonth,     rMinute,
        rYz_iSTRG[ 300 ],   rDay,       rSecond,
        rTz_iSTRG[ 300 ]
    ;
   
    va_format( rTz_iSTRG, sizeof( rTz_iSTRG ), Log_Par, va_start< 3 > );
   
    getdate( rYear, rMonth, rDay );
    gettime( rHour, rMinute, rSecond );
    format( rQz_iSTRG, 100,  "COMMENT: %s\r\n", Log_Com );
    format( rGz_iSTRG, 300, "(%d/%d/%d)[%02d:%02d:%d] %s\r\n\n", rDay, rMonth, rYear, rHour, rMinute , rSecond, rTz_iSTRG );
   
    strcat( rQz_iSTRG, rGz_iSTRG );
    strcat( rYz_iSTRG, rQz_iSTRG );
   
    new File:File_r = fopen( Log_File, io_append );
    fwrite( File_r, rYz_iSTRG );
    fclose( File_r );

    return 1;
}

stock DeleteLog( const Log_File[ ] )
{
    if( !LogExist( Log_File ) )
    {
        printf("This log doesn't exist.");
        return 0;
    }
    fremove( Log_File );

    return 1;
}
Reply


Messages In This Thread
rLogs | Server logs [y_va] - by Rock - 19.02.2013, 13:54
Re: rLogs | Server logs - by rVar - 19.02.2013, 14:05
Re: rLogs | Server logs - by Rock - 19.02.2013, 16:33
Re: rLogs | Server logs - by DanLore - 20.02.2013, 11:07
Re: rLogs | Server logs - by [L4T]Left4Theft - 25.02.2013, 14:29
Re: rLogs | Server logs - by Apenmeeuw - 25.02.2013, 14:32
Re: rLogs | Server logs - by sDAAw - 25.03.2013, 08:28
Re: rLogs | Server logs - by RajatPawar - 25.03.2013, 09:19
Re: rLogs | Server logs - by Rock - 25.03.2013, 11:57
Re: rLogs | Server logs - by Rock - 25.03.2013, 12:13

Forum Jump:


Users browsing this thread: 1 Guest(s)