move log files from the header to local globals
This commit is contained in:
+14
-12
@@ -75,6 +75,8 @@ map<CString, CString> LogMaps;
|
|||||||
#define INFO_PATH SYS_BASE_PATH "info.txt"
|
#define INFO_PATH SYS_BASE_PATH "info.txt"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static FILE *g_fileLog, *g_fileInfo;
|
||||||
|
|
||||||
#if defined(HAVE_VERSION_INFO)
|
#if defined(HAVE_VERSION_INFO)
|
||||||
extern unsigned long version_num;
|
extern unsigned long version_num;
|
||||||
extern const char *version_time;
|
extern const char *version_time;
|
||||||
@@ -102,16 +104,16 @@ RageLog::RageLog()
|
|||||||
remove( INFO_PATH );
|
remove( INFO_PATH );
|
||||||
|
|
||||||
// Open log file and leave it open.
|
// Open log file and leave it open.
|
||||||
m_fileLog = fopen( LOG_PATH, "w" );
|
g_fileLog = fopen( LOG_PATH, "w" );
|
||||||
|
|
||||||
// Failing to open shouldn't be fatal
|
// Failing to open shouldn't be fatal
|
||||||
//if( m_fileLog == NULL )
|
//if( g_fileLog == NULL )
|
||||||
// RageException::Throw( " Couldn't open log.txt: %s", strerror(errno) );
|
// RageException::Throw( " Couldn't open log.txt: %s", strerror(errno) );
|
||||||
|
|
||||||
m_fileInfo = fopen( INFO_PATH, "w" );
|
g_fileInfo = fopen( INFO_PATH, "w" );
|
||||||
|
|
||||||
// Failing to open shouldn't be fatal
|
// Failing to open shouldn't be fatal
|
||||||
//if( m_fileInfo == NULL )
|
//if( g_fileInfo == NULL )
|
||||||
// RageException::Throw( " Couldn't open info.txt: %s", strerror(errno) );
|
// RageException::Throw( " Couldn't open info.txt: %s", strerror(errno) );
|
||||||
|
|
||||||
this->Info( PRODUCT_NAME_VER );
|
this->Info( PRODUCT_NAME_VER );
|
||||||
@@ -151,8 +153,8 @@ RageLog::~RageLog()
|
|||||||
|
|
||||||
Flush();
|
Flush();
|
||||||
ShowLogOutput( false );
|
ShowLogOutput( false );
|
||||||
if(m_fileLog) fclose( m_fileLog );
|
if(g_fileLog) fclose( g_fileLog );
|
||||||
if(m_fileInfo) fclose( m_fileInfo );
|
if(g_fileInfo) fclose( g_fileInfo );
|
||||||
}
|
}
|
||||||
|
|
||||||
void RageLog::SetLogging( bool b )
|
void RageLog::SetLogging( bool b )
|
||||||
@@ -236,8 +238,8 @@ void RageLog::Write( int where, CString str)
|
|||||||
if( m_bTimestamping )
|
if( m_bTimestamping )
|
||||||
str = SecondsToTime(RageTimer::GetTimeSinceStart()) + ": " + str;
|
str = SecondsToTime(RageTimer::GetTimeSinceStart()) + ": " + str;
|
||||||
|
|
||||||
if( where&WRITE_TO_INFO && m_fileInfo )
|
if( where&WRITE_TO_INFO && g_fileInfo )
|
||||||
fprintf(m_fileInfo, "%s\n", str.c_str() );
|
fprintf(g_fileInfo, "%s\n", str.c_str() );
|
||||||
|
|
||||||
if( HOOKS )
|
if( HOOKS )
|
||||||
HOOKS->Log( str, where & WRITE_TO_INFO );
|
HOOKS->Log( str, where & WRITE_TO_INFO );
|
||||||
@@ -258,8 +260,8 @@ void RageLog::Write( int where, CString str)
|
|||||||
str.c_str());
|
str.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if( m_fileLog )
|
if( g_fileLog )
|
||||||
fprintf(m_fileLog, "%s\n", str.c_str() );
|
fprintf(g_fileLog, "%s\n", str.c_str() );
|
||||||
|
|
||||||
if( m_bShowLogOutput || where != 0 )
|
if( m_bShowLogOutput || where != 0 )
|
||||||
printf("%s\n", str.c_str() );
|
printf("%s\n", str.c_str() );
|
||||||
@@ -271,8 +273,8 @@ void RageLog::Write( int where, CString str)
|
|||||||
|
|
||||||
void RageLog::Flush()
|
void RageLog::Flush()
|
||||||
{
|
{
|
||||||
fflush( m_fileLog );
|
fflush( g_fileLog );
|
||||||
fflush( m_fileInfo );
|
fflush( g_fileInfo );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ private:
|
|||||||
bool m_bFlush;
|
bool m_bFlush;
|
||||||
bool m_bTimestamping;
|
bool m_bTimestamping;
|
||||||
bool m_bShowLogOutput;
|
bool m_bShowLogOutput;
|
||||||
FILE *m_fileLog, *m_fileInfo;
|
|
||||||
void Write( int, CString );
|
void Write( int, CString );
|
||||||
void UpdateMappedLog();
|
void UpdateMappedLog();
|
||||||
void AddToInfo( CString buf );
|
void AddToInfo( CString buf );
|
||||||
|
|||||||
Reference in New Issue
Block a user