try using RageFile for logging

This commit is contained in:
Glenn Maynard
2003-12-12 08:22:03 +00:00
parent 6a572e1e3a
commit 0d0b0d3f12
2 changed files with 15 additions and 15 deletions
+11 -11
View File
@@ -75,7 +75,7 @@ map<CString, CString> LogMaps;
#define INFO_PATH SYS_BASE_PATH "info.txt"
#endif
static FILE *g_fileLog, *g_fileInfo;
static RageFile g_fileLog, g_fileInfo;
#if defined(HAVE_VERSION_INFO)
extern unsigned long version_num;
@@ -104,13 +104,13 @@ RageLog::RageLog()
remove( INFO_PATH );
// Open log file and leave it open.
g_fileLog = fopen( LOG_PATH, "w" );
g_fileLog.Open( LOG_PATH, RageFile::WRITE );
// Failing to open shouldn't be fatal
//if( g_fileLog == NULL )
// RageException::Throw( " Couldn't open log.txt: %s", strerror(errno) );
g_fileInfo = fopen( INFO_PATH, "w" );
g_fileInfo.Open( INFO_PATH, RageFile::WRITE );
// Failing to open shouldn't be fatal
//if( g_fileInfo == NULL )
@@ -153,8 +153,8 @@ RageLog::~RageLog()
Flush();
ShowLogOutput( false );
if(g_fileLog) fclose( g_fileLog );
if(g_fileInfo) fclose( g_fileInfo );
g_fileLog.Close();
g_fileInfo.Close();
}
void RageLog::SetLogging( bool b )
@@ -238,8 +238,8 @@ void RageLog::Write( int where, CString str)
if( m_bTimestamping )
str = SecondsToTime(RageTimer::GetTimeSinceStart()) + ": " + str;
if( where&WRITE_TO_INFO && g_fileInfo )
fprintf(g_fileInfo, "%s\n", str.c_str() );
if( where&WRITE_TO_INFO && g_fileInfo.IsOpen() )
g_fileInfo.PutLine( str );
if( HOOKS )
HOOKS->Log( str, where & WRITE_TO_INFO );
@@ -260,8 +260,8 @@ void RageLog::Write( int where, CString str)
str.c_str());
}
if( g_fileLog )
fprintf(g_fileLog, "%s\n", str.c_str() );
if( g_fileLog.IsOpen() )
g_fileLog.PutLine( str );
if( m_bShowLogOutput || where != 0 )
printf("%s\n", str.c_str() );
@@ -273,8 +273,8 @@ void RageLog::Write( int where, CString str)
void RageLog::Flush()
{
fflush( g_fileLog );
fflush( g_fileInfo );
g_fileLog.Flush();
g_fileInfo.Flush();
}
+4 -4
View File
@@ -816,15 +816,15 @@ int main(int argc, char* argv[])
ChangeToDirOfExecutable(argv[0]);
/* Set this up second. Do this early, since it's needed for RageException::Throw.
/* Almost everything uses this to read and write files. Load this early. */
FILEMAN = new RageFileManager;
/* Set this up next. Do this early, since it's needed for RageException::Throw.
* Do it after ChangeToDirOfExecutable, so the log ends up in the right place. */
LOG = new RageLog();
/* Whew--we should be able to crash safely now! */
/* Everything except LOG uses this to read and write files. Load this early. */
FILEMAN = new RageFileManager;
MountTreeOfZips( ZIPS_DIR );
atexit(SDL_Quit); /* Clean up on exit */