Browse Source

Fix log

pull/2/head
mittorn 7 years ago
parent
commit
42b4e456a2
  1. 1
      engine/common/host.c
  2. 14
      engine/common/sys_con.c

1
engine/common/host.c

@ -1014,4 +1014,5 @@ void EXPORT Host_Shutdown( void ) @@ -1014,4 +1014,5 @@ void EXPORT Host_Shutdown( void )
// restore filter
Sys_RestoreCrashHandler();
Sys_CloseLog();
}

14
engine/common/sys_con.c

@ -94,6 +94,12 @@ void Sys_InitLog( void ) @@ -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 ) @@ -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 ) @@ -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 );
}

Loading…
Cancel
Save