project64/Source/Common/Trace.h

44 lines
1.3 KiB
C
Raw Normal View History

2015-10-25 11:10:54 +00:00
#pragma once
#include "CriticalSection.h"
#include "Log Class.h"
2015-10-25 11:10:54 +00:00
class CTraceModule
{
2015-10-25 11:10:54 +00:00
TraceLevel m_Type;
public:
2015-10-25 11:10:54 +00:00
CTraceModule () { m_Type = TrLvError; }
virtual ~CTraceModule () {}
2015-10-25 11:10:54 +00:00
inline void SetTraceLevel ( TraceLevel Type ) { m_Type = Type; }
inline TraceLevel GetTraceLevel ( void ) const { return m_Type; }
virtual void Write ( const char * Message, bool EndOfLine ) = 0;
};
class CTraceFileLog : public CTraceModule
{
2015-10-25 11:10:54 +00:00
enum { MB = 1024 * 1024 };
2015-10-25 11:10:54 +00:00
CriticalSection m_CriticalSection;
CLog m_hLogFile;
bool m_FlushFile;
public:
CTraceFileLog (const char * FileName, bool FlushFile = true);
CTraceFileLog (const char * FileName, bool FlushFile, LOG_OPEN_MODE eMode, uint32_t dwMaxFileSize = 5);
2015-10-25 11:10:54 +00:00
virtual ~CTraceFileLog ();
void Write ( const char * Message, bool EndOfLine );
2015-10-25 11:10:54 +00:00
void SetFlushFile ( bool bFlushFile );
};
class CDebugTraceLog : public CTraceModule
{
2015-10-25 11:10:54 +00:00
public:
void Write ( const char * Message, bool EndOfLine );
};
CTraceModule * AddTraceModule ( CTraceModule * TraceModule ); // Must be created with new
CTraceModule * RemoveTraceModule ( CTraceModule * TraceModule ); // Is not automaticly deleted