[Common] Clean up log class
This commit is contained in:
parent
f5cf17903b
commit
b93421c502
|
@ -1,25 +1,18 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include "FileClass.h"
|
||||
#include "StdString.h"
|
||||
|
||||
enum LOG_OPEN_MODE
|
||||
{
|
||||
Log_New, Log_Append
|
||||
};
|
||||
|
||||
class CLog
|
||||
{
|
||||
public:
|
||||
enum LOG_OPEN_MODE
|
||||
{
|
||||
Log_New, Log_Append
|
||||
};
|
||||
|
||||
enum { MB = 1024 * 1024 };
|
||||
enum { MAX_FILE_SIZE = 10 * MB };
|
||||
|
||||
CFile m_hLogFile;
|
||||
bool m_FlushOnWrite;
|
||||
stdstr m_FileName;
|
||||
bool m_TruncateFileLog;
|
||||
uint32_t m_MaxFileSize;
|
||||
uint32_t m_FileChangeSize;
|
||||
|
||||
public:
|
||||
|
||||
CLog(void);
|
||||
~CLog(void);
|
||||
|
||||
|
@ -36,8 +29,19 @@ public:
|
|||
m_FileChangeSize = (uint32_t)(Size * 0.1);
|
||||
}
|
||||
inline void SetTruncateFile(bool Truncate) { m_TruncateFileLog = Truncate; }
|
||||
inline void SetFlush(bool Always) { m_FlushOnWrite = Always; }
|
||||
inline void SetFlush(bool Always) { m_FlushOnWrite = Always; }
|
||||
inline bool IsOpen(void) const { return m_hLogFile.IsOpen(); }
|
||||
inline bool Flush(void) { return m_hLogFile.Flush(); }
|
||||
inline const stdstr & FileName(void) const { return m_FileName; }
|
||||
inline bool Flush(void) { return m_hLogFile.Flush(); }
|
||||
inline const std::string & FileName(void) const { return m_FileName; }
|
||||
|
||||
private:
|
||||
CLog(const CLog&); // Disable copy constructor
|
||||
CLog& operator=(const CLog&); // Disable assignment
|
||||
|
||||
CFile m_hLogFile;
|
||||
bool m_FlushOnWrite;
|
||||
std::string m_FileName;
|
||||
bool m_TruncateFileLog;
|
||||
uint32_t m_MaxFileSize;
|
||||
uint32_t m_FileChangeSize;
|
||||
};
|
||||
|
|
|
@ -171,8 +171,8 @@ const char * TraceModule(uint32_t module)
|
|||
return Unknown.c_str();
|
||||
}
|
||||
|
||||
CTraceFileLog::CTraceFileLog(const char * FileName, bool FlushFile, LOG_OPEN_MODE eMode, size_t dwMaxFileSize) :
|
||||
m_FlushFile(FlushFile)
|
||||
CTraceFileLog::CTraceFileLog(const char * FileName, bool FlushFile, CLog::LOG_OPEN_MODE eMode, size_t dwMaxFileSize) :
|
||||
m_FlushFile(FlushFile)
|
||||
{
|
||||
enum { MB = 1024 * 1024 };
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ __interface CTraceModule
|
|||
class CTraceFileLog : public CTraceModule
|
||||
{
|
||||
public:
|
||||
CTraceFileLog(const char * FileName, bool FlushFile, LOG_OPEN_MODE eMode, size_t dwMaxFileSize = 5);
|
||||
CTraceFileLog(const char * FileName, bool FlushFile, CLog::LOG_OPEN_MODE eMode, size_t dwMaxFileSize = 5);
|
||||
virtual ~CTraceFileLog();
|
||||
|
||||
void SetFlushFile(bool bFlushFile);
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "DepthBufferRender.h"
|
||||
#include "Config.h"
|
||||
#include "trace.h"
|
||||
#include <Common/StdString.h>
|
||||
|
||||
short Set_basic_mode = 0, Set_texture_dir = 0, Set_log_dir = 0, Set_log_flush = 0;
|
||||
|
||||
|
|
|
@ -84,6 +84,6 @@ void SetupTrace(void)
|
|||
LogFilePath.DirectoryCreate();
|
||||
}
|
||||
LogFilePath.SetNameExtension("Glide64.log");
|
||||
g_LogFile = new CTraceFileLog(LogFilePath, GetSystemSetting(Set_log_flush) != 0, Log_New, 500);
|
||||
g_LogFile = new CTraceFileLog(LogFilePath, GetSystemSetting(Set_log_flush) != 0, CLog::Log_New, 500);
|
||||
TraceAddModule(g_LogFile);
|
||||
}
|
|
@ -44,7 +44,7 @@ void AddLogModule(void)
|
|||
}
|
||||
LogFilePath.SetNameExtension("Project64.log");
|
||||
|
||||
g_LogFile = new CTraceFileLog(LogFilePath, g_Settings->LoadDword(Debugger_AppLogFlush) != 0, Log_New, 500);
|
||||
g_LogFile = new CTraceFileLog(LogFilePath, g_Settings->LoadDword(Debugger_AppLogFlush) != 0, CLog::Log_New, 500);
|
||||
TraceAddModule(g_LogFile);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue