better log control for test set
This commit is contained in:
+35
-33
@@ -19,7 +19,6 @@
|
|||||||
#include "RageFile.h"
|
#include "RageFile.h"
|
||||||
#include "RageThreads.h"
|
#include "RageThreads.h"
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "ProductInfo.h"
|
|
||||||
#if defined(_WINDOWS)
|
#if defined(_WINDOWS)
|
||||||
#include "windows.h"
|
#include "windows.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -67,10 +66,8 @@ RageLog* LOG; // global and accessable from anywhere in the program
|
|||||||
* map/unmap, using any mechanism to generate unique IDs. */
|
* map/unmap, using any mechanism to generate unique IDs. */
|
||||||
map<CString, CString> LogMaps;
|
map<CString, CString> LogMaps;
|
||||||
|
|
||||||
// constants
|
#define LOG_PATH "log.txt"
|
||||||
/* We need to use SYS_BASE_PATH here, because this doesn't go through RageFile. */
|
#define INFO_PATH "info.txt"
|
||||||
#define LOG_PATH SYS_BASE_PATH "log.txt"
|
|
||||||
#define INFO_PATH SYS_BASE_PATH "info.txt"
|
|
||||||
|
|
||||||
static RageFile *g_fileLog, *g_fileInfo;
|
static RageFile *g_fileLog, *g_fileInfo;
|
||||||
|
|
||||||
@@ -78,11 +75,6 @@ static RageFile *g_fileLog, *g_fileInfo;
|
|||||||
* only place we write to the same file from multiple threads. */
|
* only place we write to the same file from multiple threads. */
|
||||||
RageMutex *g_Mutex;
|
RageMutex *g_Mutex;
|
||||||
|
|
||||||
#if defined(HAVE_VERSION_INFO)
|
|
||||||
extern unsigned long version_num;
|
|
||||||
extern const char *version_time;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* staticlog gets info.txt
|
/* staticlog gets info.txt
|
||||||
* crashlog gets log.txt */
|
* crashlog gets log.txt */
|
||||||
enum {
|
enum {
|
||||||
@@ -101,7 +93,8 @@ RageLog::RageLog()
|
|||||||
|
|
||||||
g_Mutex = new RageMutex;
|
g_Mutex = new RageMutex;
|
||||||
|
|
||||||
m_bLogToDisk = true;
|
m_bLogToDisk = false;
|
||||||
|
m_bInfoToDisk = false;
|
||||||
m_bFlush = false;
|
m_bFlush = false;
|
||||||
m_bTimestamping = false;
|
m_bTimestamping = false;
|
||||||
m_bShowLogOutput = false;
|
m_bShowLogOutput = false;
|
||||||
@@ -109,28 +102,6 @@ RageLog::RageLog()
|
|||||||
// delete old log files
|
// delete old log files
|
||||||
remove( LOG_PATH );
|
remove( LOG_PATH );
|
||||||
remove( INFO_PATH );
|
remove( INFO_PATH );
|
||||||
|
|
||||||
// Open log file and leave it open.
|
|
||||||
if( !g_fileLog->Open( LOG_PATH, RageFile::WRITE|RageFile::STREAMED ) )
|
|
||||||
fprintf( stderr, "Couldn't open %s: %s\n", LOG_PATH, g_fileLog->GetError().c_str() );
|
|
||||||
|
|
||||||
if( !g_fileInfo->Open( INFO_PATH, RageFile::WRITE|RageFile::STREAMED ) )
|
|
||||||
fprintf( stderr, "Couldn't open %s: %s\n", INFO_PATH, g_fileInfo->GetError().c_str() );
|
|
||||||
|
|
||||||
this->Info( PRODUCT_NAME_VER );
|
|
||||||
|
|
||||||
#if defined(HAVE_VERSION_INFO)
|
|
||||||
this->Info( "Compiled %s (build %lu)", version_time, version_num );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
time_t cur_time;
|
|
||||||
time(&cur_time);
|
|
||||||
struct tm now;
|
|
||||||
localtime_r( &cur_time, &now );
|
|
||||||
|
|
||||||
this->Info( "Log starting %.4d-%.2d-%.2d %.2d:%.2d:%.2d",
|
|
||||||
1900+now.tm_year, now.tm_mon+1, now.tm_mday, now.tm_hour+1, now.tm_min, now.tm_sec );
|
|
||||||
this->Trace( " " );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RageLog::~RageLog()
|
RageLog::~RageLog()
|
||||||
@@ -162,7 +133,38 @@ RageLog::~RageLog()
|
|||||||
|
|
||||||
void RageLog::SetLogToDisk( bool b )
|
void RageLog::SetLogToDisk( bool b )
|
||||||
{
|
{
|
||||||
|
if( m_bLogToDisk == b )
|
||||||
|
return;
|
||||||
|
|
||||||
m_bLogToDisk = b;
|
m_bLogToDisk = b;
|
||||||
|
|
||||||
|
if( !m_bLogToDisk )
|
||||||
|
{
|
||||||
|
if( g_fileLog->IsOpen() )
|
||||||
|
g_fileLog->Close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !g_fileLog->Open( LOG_PATH, RageFile::WRITE|RageFile::STREAMED ) )
|
||||||
|
fprintf( stderr, "Couldn't open %s: %s\n", LOG_PATH, g_fileLog->GetError().c_str() );
|
||||||
|
}
|
||||||
|
|
||||||
|
void RageLog::SetInfoToDisk( bool b )
|
||||||
|
{
|
||||||
|
if( m_bInfoToDisk == b )
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_bInfoToDisk = b;
|
||||||
|
|
||||||
|
if( !m_bInfoToDisk )
|
||||||
|
{
|
||||||
|
if( g_fileInfo->IsOpen() )
|
||||||
|
g_fileInfo->Close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !g_fileInfo->Open( INFO_PATH, RageFile::WRITE|RageFile::STREAMED ) )
|
||||||
|
fprintf( stderr, "Couldn't open %s: %s\n", INFO_PATH, g_fileInfo->GetError().c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void RageLog::SetFlushing( bool b )
|
void RageLog::SetFlushing( bool b )
|
||||||
|
|||||||
@@ -33,11 +33,13 @@ public:
|
|||||||
|
|
||||||
void SetShowLogOutput( bool show ); // enable or disable logging to stdout
|
void SetShowLogOutput( bool show ); // enable or disable logging to stdout
|
||||||
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 SetFlushing( bool b ); // enable or disable flushing
|
void SetFlushing( bool b ); // enable or disable flushing
|
||||||
void SetTimestamping( bool b ); // enable or disable timestamping
|
void SetTimestamping( bool b ); // enable or disable timestamping
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_bLogToDisk;
|
bool m_bLogToDisk;
|
||||||
|
bool m_bInfoToDisk;
|
||||||
bool m_bFlush;
|
bool m_bFlush;
|
||||||
bool m_bTimestamping;
|
bool m_bTimestamping;
|
||||||
bool m_bShowLogOutput;
|
bool m_bShowLogOutput;
|
||||||
|
|||||||
@@ -29,6 +29,8 @@
|
|||||||
#include "arch/LoadingWindow/LoadingWindow.h"
|
#include "arch/LoadingWindow/LoadingWindow.h"
|
||||||
#include "time.h"
|
#include "time.h"
|
||||||
|
|
||||||
|
#include "ProductInfo.h"
|
||||||
|
|
||||||
#include "SDL_utils.h"
|
#include "SDL_utils.h"
|
||||||
|
|
||||||
#include "Screen.h"
|
#include "Screen.h"
|
||||||
@@ -805,6 +807,31 @@ void __cdecl main()
|
|||||||
*/
|
*/
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_VERSION_INFO)
|
||||||
|
extern unsigned long version_num;
|
||||||
|
extern const char *version_time;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static void WriteLogHeader()
|
||||||
|
{
|
||||||
|
|
||||||
|
LOG->Info( PRODUCT_NAME_VER );
|
||||||
|
|
||||||
|
#if defined(HAVE_VERSION_INFO)
|
||||||
|
LOG->Info( "Compiled %s (build %lu)", version_time, version_num );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
time_t cur_time;
|
||||||
|
time(&cur_time);
|
||||||
|
struct tm now;
|
||||||
|
localtime_r( &cur_time, &now );
|
||||||
|
|
||||||
|
LOG->Info( "Log starting %.4d-%.2d-%.2d %.2d:%.2d:%.2d",
|
||||||
|
1900+now.tm_year, now.tm_mon+1, now.tm_mday, now.tm_hour+1, now.tm_min, now.tm_sec );
|
||||||
|
LOG->Trace( " " );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
#ifdef _XBOX
|
#ifdef _XBOX
|
||||||
@@ -881,10 +908,12 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
LOG->SetShowLogOutput( PREFSMAN->m_bShowLogOutput );
|
LOG->SetShowLogOutput( PREFSMAN->m_bShowLogOutput );
|
||||||
LOG->SetLogToDisk( PREFSMAN->m_bLogToDisk );
|
LOG->SetLogToDisk( PREFSMAN->m_bLogToDisk );
|
||||||
|
LOG->SetInfoToDisk( true );
|
||||||
LOG->SetFlushing( PREFSMAN->m_bForceLogFlush );
|
LOG->SetFlushing( PREFSMAN->m_bForceLogFlush );
|
||||||
LOG->SetTimestamping( PREFSMAN->m_bTimestamping );
|
LOG->SetTimestamping( PREFSMAN->m_bTimestamping );
|
||||||
Checkpoints::LogCheckpoints( PREFSMAN->m_bLogCheckpoints );
|
Checkpoints::LogCheckpoints( PREFSMAN->m_bLogCheckpoints );
|
||||||
|
|
||||||
|
WriteLogHeader();
|
||||||
|
|
||||||
/* This requires PREFSMAN, for PREFSMAN->m_bShowLoadingWindow. */
|
/* This requires PREFSMAN, for PREFSMAN->m_bShowLoadingWindow. */
|
||||||
LoadingWindow *loading_window = MakeLoadingWindow();
|
LoadingWindow *loading_window = MakeLoadingWindow();
|
||||||
|
|||||||
Reference in New Issue
Block a user