From e67a10875992a4ef71557404e11089b4c0618dd4 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Fri, 19 Dec 2003 00:53:45 +0000 Subject: [PATCH] handle multi-line logs --- stepmania/src/RageLog.cpp | 63 ++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 28 deletions(-) diff --git a/stepmania/src/RageLog.cpp b/stepmania/src/RageLog.cpp index 53d7f721ee..98a165e06b 100644 --- a/stepmania/src/RageLog.cpp +++ b/stepmania/src/RageLog.cpp @@ -225,41 +225,48 @@ void RageLog::Warn( const char *fmt, ...) CString sBuff = vssprintf( fmt, va ); va_end(va); - Write(WRITE_TO_INFO | WRITE_LOUD, ssprintf("WARNING: %s", sBuff.c_str())); + Write( WRITE_TO_INFO | WRITE_LOUD, sBuff ); } -void RageLog::Write( int where, CString str) +void RageLog::Write( int where, CString line ) { - if( m_bTimestamping ) - str = SecondsToTime(RageTimer::GetTimeSinceStart()) + ": " + str; - - if( where&WRITE_TO_INFO && g_fileInfo.IsOpen() ) - g_fileInfo.PutLine( str ); - - if( HOOKS ) - HOOKS->Log( str, where & WRITE_TO_INFO ); - - if( where & WRITE_TO_INFO ) - AddToInfo( str ); - AddToRecentLogs( str ); - - /* Only do this for log.txt and stdout. The other outputs are - * fairly quiet anyway, so the prepended "WARNING" makes them stand - * out well enough and this is just clutter. */ + vector lines; + split( line, "\n", lines, false ); + if( g_fileLog.IsOpen() && (where & WRITE_LOUD) ) + g_fileLog.PutLine( "/////////////////////////////////////////" ); if( where & WRITE_LOUD ) + printf( "/////////////////////////////////////////\n" ); + + for( unsigned i = 0; i < lines.size(); ++i ) { - str = ssprintf( - "/////////////////////////////////////////\n" - "%s\n" - "/////////////////////////////////////////", - str.c_str()); + CString &str = lines[i]; + + if( where & WRITE_LOUD ) + str = "WARNING: " + str; + if( m_bTimestamping ) + str = SecondsToTime(RageTimer::GetTimeSinceStart()) + ": " + str; + + if( where&WRITE_TO_INFO && g_fileInfo.IsOpen() ) + g_fileInfo.PutLine( str ); + + if( HOOKS ) + HOOKS->Log( str, where & WRITE_TO_INFO ); + + if( where & WRITE_TO_INFO ) + AddToInfo( str ); + AddToRecentLogs( str ); + + if( g_fileLog.IsOpen() ) + g_fileLog.PutLine( str ); + + if( m_bShowLogOutput || where != 0 ) + printf("%s\n", str.c_str() ); } - if( g_fileLog.IsOpen() ) - g_fileLog.PutLine( str ); - - if( m_bShowLogOutput || where != 0 ) - printf("%s\n", str.c_str() ); + if( g_fileLog.IsOpen() && (where & WRITE_LOUD) ) + g_fileLog.PutLine( "/////////////////////////////////////////" ); + if( where & WRITE_LOUD ) + printf( "/////////////////////////////////////////\n" ); if( m_bFlush || (where & WRITE_TO_INFO) ) Flush();