Browse Source

engine: common: don't output log to stdout on Win32 where it's done by Wcon. Better colorcode filtration

pull/2/head
Alibek Omarov 2 years ago
parent
commit
347c6d6a91
  1. 31
      engine/common/sys_con.c

31
engine/common/sys_con.c

@ -24,7 +24,7 @@ GNU General Public License for more details. @@ -24,7 +24,7 @@ GNU General Public License for more details.
#include <errno.h>
#if !XASH_WIN32 && !XASH_MOBILE_PLATFORM
#define XASH_COLORIZE_CONSOLE
// #define XASH_COLORIZE_CONSOLE
// use with caution, running engine in Qt Creator may cause a freeze in read() call
// I was never encountered this bug anywhere else, so still enable by default
// #define XASH_USE_SELECT 1
@ -227,17 +227,32 @@ static void Sys_PrintColorized( const char *logtime, const char *msg ) @@ -227,17 +227,32 @@ static void Sys_PrintColorized( const char *logtime, const char *msg )
static void Sys_PrintFile( int fd, const char *logtime, const char *msg )
{
const char *p = msg;
write( fd, logtime, Q_strlen( logtime ) );
while ( *msg )
while( p && *p )
{
const char *p = strchr( msg, '^' );
p = Q_strchr( msg, '^' );
if ( p && IsColorString( p ) )
if( p == NULL )
{
write( fd, msg, Q_strlen( msg ));
break;
}
else if( IsColorString( p ))
{
if( p != msg )
{
msg += write( fd, msg, p - msg );
msg += 2;
} else msg += write( fd, msg, Q_strlen( msg ) );
write( fd, msg, p - msg );
}
msg = p + 2;
}
else
{
write( fd, msg, p - msg + 1 );
msg = p + 1;
}
}
}
@ -279,7 +294,7 @@ void Sys_PrintLog( const char *pMsg ) @@ -279,7 +294,7 @@ void Sys_PrintLog( const char *pMsg )
// spew to stdout
#ifdef XASH_COLORIZE_CONSOLE
Sys_PrintColorized( logtime, pMsg );
#else
#elif !XASH_WIN32 // Wcon already does the job
Sys_PrintStdout( logtime, pMsg );
#endif
Sys_FlushStdout();

Loading…
Cancel
Save