diff --git a/engine/common/sys_con.c b/engine/common/sys_con.c index 96f4bb98..93c0a4b5 100644 --- a/engine/common/sys_con.c +++ b/engine/common/sys_con.c @@ -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(); } diff --git a/public/crtlib.c b/public/crtlib.c index 73bafdf4..cd3cdb28 100644 --- a/public/crtlib.c +++ b/public/crtlib.c @@ -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; diff --git a/public/crtlib.h b/public/crtlib.h index 5e23423f..1cccf1e3 100644 --- a/public/crtlib.h +++ b/public/crtlib.h @@ -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 );