Always timestamp log.txt.
This commit is contained in:
+13
-19
@@ -84,7 +84,6 @@ RageLog::RageLog()
|
|||||||
m_bLogToDisk = false;
|
m_bLogToDisk = false;
|
||||||
m_bInfoToDisk = false;
|
m_bInfoToDisk = false;
|
||||||
m_bFlush = false;
|
m_bFlush = false;
|
||||||
m_bTimestamping = false;
|
|
||||||
m_bShowLogOutput = false;
|
m_bShowLogOutput = false;
|
||||||
|
|
||||||
// delete old log files
|
// delete old log files
|
||||||
@@ -160,11 +159,6 @@ void RageLog::SetFlushing( bool b )
|
|||||||
m_bFlush = b;
|
m_bFlush = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RageLog::SetTimestamping( bool b )
|
|
||||||
{
|
|
||||||
m_bTimestamping = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Enable or disable display of output to stdout, or a console window in Windows. */
|
/* Enable or disable display of output to stdout, or a console window in Windows. */
|
||||||
void RageLog::SetShowLogOutput( bool show )
|
void RageLog::SetShowLogOutput( bool show )
|
||||||
{
|
{
|
||||||
@@ -228,31 +222,33 @@ void RageLog::Write( int where, const CString &line )
|
|||||||
if( where & WRITE_LOUD )
|
if( where & WRITE_LOUD )
|
||||||
printf( "/////////////////////////////////////////\n" );
|
printf( "/////////////////////////////////////////\n" );
|
||||||
|
|
||||||
CString LineHeader;
|
CString sTimestamp = SecondsToMMSSMsMsMs(RageTimer::GetTimeSinceStart()) + ": ";
|
||||||
if( m_bTimestamping )
|
CString sWarning;
|
||||||
LineHeader += SecondsToMMSSMsMsMs(RageTimer::GetTimeSinceStart()) + ": ";
|
|
||||||
if( where & WRITE_LOUD )
|
if( where & WRITE_LOUD )
|
||||||
LineHeader += "WARNING: ";
|
sWarning = "WARNING: ";
|
||||||
|
|
||||||
for( unsigned i = 0; i < lines.size(); ++i )
|
for( unsigned i = 0; i < lines.size(); ++i )
|
||||||
{
|
{
|
||||||
CString &str = lines[i];
|
CString &str = lines[i];
|
||||||
|
|
||||||
if( LineHeader.size() )
|
if( sWarning.size() )
|
||||||
str.insert( 0, LineHeader );
|
str.insert( 0, sWarning );
|
||||||
|
|
||||||
|
if( m_bShowLogOutput || where != 0 )
|
||||||
|
printf("%s\n", str.c_str() );
|
||||||
|
if( where & WRITE_TO_INFO )
|
||||||
|
AddToInfo( str );
|
||||||
if( m_bLogToDisk && where&WRITE_TO_INFO && g_fileInfo->IsOpen() )
|
if( m_bLogToDisk && where&WRITE_TO_INFO && g_fileInfo->IsOpen() )
|
||||||
g_fileInfo->PutLine( str );
|
g_fileInfo->PutLine( str );
|
||||||
|
|
||||||
if( where & WRITE_TO_INFO )
|
/* Add a timestamp to log.txt and RecentLogs, but not the rest of info.txt
|
||||||
AddToInfo( str );
|
* and stdout. */
|
||||||
|
str.insert( 0, sTimestamp );
|
||||||
|
|
||||||
AddToRecentLogs( str );
|
AddToRecentLogs( str );
|
||||||
|
|
||||||
if( m_bLogToDisk && g_fileLog->IsOpen() )
|
if( m_bLogToDisk && g_fileLog->IsOpen() )
|
||||||
g_fileLog->PutLine( str );
|
g_fileLog->PutLine( str );
|
||||||
|
|
||||||
if( m_bShowLogOutput || where != 0 )
|
|
||||||
printf("%s\n", str.c_str() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( m_bLogToDisk && g_fileLog->IsOpen() && (where & WRITE_LOUD) )
|
if( m_bLogToDisk && g_fileLog->IsOpen() && (where & WRITE_LOUD) )
|
||||||
@@ -371,8 +367,6 @@ const char *RageLog::GetAdditionalLog()
|
|||||||
void RageLog::MapLog(const CString &key, const char *fmt, ...)
|
void RageLog::MapLog(const CString &key, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
CString s;
|
CString s;
|
||||||
if( m_bTimestamping )
|
|
||||||
s += SecondsToMMSSMsMsMs(RageTimer::GetTimeSinceStart()) + ": ";
|
|
||||||
|
|
||||||
va_list va;
|
va_list va;
|
||||||
va_start(va, fmt);
|
va_start(va, fmt);
|
||||||
|
|||||||
@@ -28,13 +28,11 @@ public:
|
|||||||
void SetLogToDisk( bool b ); // enable or disable logging to file
|
void SetLogToDisk( bool b ); // enable or disable logging to file
|
||||||
void SetInfoToDisk( bool b ); // enable or disable logging info.txt to file
|
void SetInfoToDisk( bool b ); // enable or disable logging info.txt to file
|
||||||
void SetFlushing( bool b ); // enable or disable flushing
|
void SetFlushing( bool b ); // enable or disable flushing
|
||||||
void SetTimestamping( bool b ); // enable or disable timestamping
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_bLogToDisk;
|
bool m_bLogToDisk;
|
||||||
bool m_bInfoToDisk;
|
bool m_bInfoToDisk;
|
||||||
bool m_bFlush;
|
bool m_bFlush;
|
||||||
bool m_bTimestamping;
|
|
||||||
bool m_bShowLogOutput;
|
bool m_bShowLogOutput;
|
||||||
void Write( int, const CString &str );
|
void Write( int, const CString &str );
|
||||||
void UpdateMappedLog();
|
void UpdateMappedLog();
|
||||||
|
|||||||
@@ -864,7 +864,6 @@ static void ApplyLogPreferences()
|
|||||||
LOG->SetLogToDisk( PREFSMAN->m_bLogToDisk );
|
LOG->SetLogToDisk( PREFSMAN->m_bLogToDisk );
|
||||||
LOG->SetInfoToDisk( true );
|
LOG->SetInfoToDisk( true );
|
||||||
LOG->SetFlushing( PREFSMAN->m_bForceLogFlush );
|
LOG->SetFlushing( PREFSMAN->m_bForceLogFlush );
|
||||||
LOG->SetTimestamping( PREFSMAN->m_bTimestamping );
|
|
||||||
Checkpoints::LogCheckpoints( PREFSMAN->m_bLogCheckpoints );
|
Checkpoints::LogCheckpoints( PREFSMAN->m_bLogCheckpoints );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user