mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-01-22 12:54:13 +00:00
engine: strip color codes when writing to log
This commit is contained in:
parent
e5562a7b61
commit
568c7fd917
@ -230,6 +230,9 @@ void Sys_PrintLog( const char *pMsg )
|
||||
time( &crt_time );
|
||||
crt_tm = localtime( &crt_time );
|
||||
|
||||
// strip color codes
|
||||
Q_cleanstr( pMsg, pMsg );
|
||||
|
||||
// platform-specific output
|
||||
#if XASH_ANDROID && !XASH_DEDICATED
|
||||
__android_log_print( ANDROID_LOG_DEBUG, "Xash", "%s", pMsg );
|
||||
@ -248,21 +251,21 @@ void Sys_PrintLog( const char *pMsg )
|
||||
#ifdef XASH_COLORIZE_CONSOLE
|
||||
Sys_PrintColorized( logtime, pMsg );
|
||||
#else
|
||||
printf( "%s %s", logtime, pMsg );
|
||||
printf( "%s%s", logtime, pMsg );
|
||||
#endif
|
||||
Sys_FlushStdout();
|
||||
#endif
|
||||
|
||||
// save last char to detect when line was not ended
|
||||
lastchar = pMsg[strlen(pMsg)-1];
|
||||
|
||||
if( !s_ld.logfile )
|
||||
return;
|
||||
|
||||
if( !lastchar || lastchar == '\n')
|
||||
strftime( logtime, sizeof( logtime ), "[%Y:%m:%d|%H:%M:%S]", crt_tm ); //full time
|
||||
strftime( logtime, sizeof( logtime ), "[%Y:%m:%d|%H:%M:%S] ", crt_tm ); //full time
|
||||
|
||||
// save last char to detect when line was not ended
|
||||
lastchar = pMsg[strlen(pMsg)-1];
|
||||
|
||||
fprintf( s_ld.logfile, "%s %s", logtime, pMsg );
|
||||
fprintf( s_ld.logfile, "%s%s", logtime, pMsg );
|
||||
Sys_FlushLogfile();
|
||||
}
|
||||
|
||||
|
@ -615,6 +615,17 @@ char *Q_strpbrk(const char *s, const char *accept)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void Q_cleanstr( const char *in, char *out )
|
||||
{
|
||||
while ( *in )
|
||||
{
|
||||
if ( IsColorString( in ) )
|
||||
in += 2;
|
||||
else *out++ = *in++;
|
||||
}
|
||||
*out = '\0';
|
||||
}
|
||||
|
||||
uint Q_hashkey( const char *string, uint hashSize, qboolean caseinsensitive )
|
||||
{
|
||||
uint i, hashKey = 0;
|
||||
|
@ -73,6 +73,7 @@ int Q_vsnprintf( char *buffer, size_t buffersize, const char *format, va_list ar
|
||||
int Q_snprintf( char *buffer, size_t buffersize, const char *format, ... ) _format( 3 );
|
||||
int Q_sprintf( char *buffer, const char *format, ... ) _format( 2 );
|
||||
char *Q_strpbrk(const char *s, const char *accept);
|
||||
void Q_cleanstr( char *in, char *out );
|
||||
#define Q_memprint( val ) Q_pretifymem( val, 2 )
|
||||
char *Q_pretifymem( float value, int digitsafterdecimal );
|
||||
char *va( const char *format, ... ) _format( 1 );
|
||||
|
Loading…
x
Reference in New Issue
Block a user