diff --git a/engine/common/host.c b/engine/common/host.c index a277d223..317ff463 100644 --- a/engine/common/host.c +++ b/engine/common/host.c @@ -1014,4 +1014,5 @@ void EXPORT Host_Shutdown( void ) // restore filter Sys_RestoreCrashHandler(); + Sys_CloseLog(); } diff --git a/engine/common/sys_con.c b/engine/common/sys_con.c index 47824edd..409f8934 100644 --- a/engine/common/sys_con.c +++ b/engine/common/sys_con.c @@ -94,6 +94,12 @@ void Sys_InitLog( void ) { const char *mode; + if( Sys_CheckParm( "-log" ) && host.allow_console != 0 ) + { + s_ld.log_active = true; + Q_strncpy( s_ld.log_path, "engine.log", sizeof( s_ld.log_path )); + } + if( host.change_game && host.type != HOST_DEDICATED ) mode = "a"; else mode = "w"; @@ -135,8 +141,7 @@ void Sys_CloseLog( void ) fprintf( s_ld.logfile, "================================================================================="); if( host.change_game ) fprintf( s_ld.logfile, "\n\t%s (build %i) %s\n", s_ld.title, Q_buildnum(), event_name ); else fprintf( s_ld.logfile, "\n\t%s (build %i) %s at %s\n", s_ld.title, Q_buildnum(), event_name, Q_timestamp( TIME_FULL )); - fprintf( s_ld.logfile, "================================================================================="); - if( host.change_game ) fprintf( s_ld.logfile, "\n" ); // just for tabulate + fprintf( s_ld.logfile, "=================================================================================\n"); fclose( s_ld.logfile ); s_ld.logfile = NULL; @@ -213,13 +218,16 @@ void Sys_PrintLog( const char *pMsg ) fflush( stdout ); #endif #endif - 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 + // save last char to detect when line was not ended + lastchar = pMsg[strlen(pMsg)-1]; + fprintf( s_ld.logfile, "%s %s", logtime, pMsg ); fflush( s_ld.logfile ); }