2015-10-25 11:10:54 +00:00
|
|
|
#pragma once
|
2015-12-04 06:49:31 +00:00
|
|
|
#include "LogClass.h"
|
2015-11-06 11:37:21 +00:00
|
|
|
|
2015-12-14 10:51:33 +00:00
|
|
|
enum TraceSeverity
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
2015-12-14 10:51:33 +00:00
|
|
|
TraceError = 0x00000001,
|
|
|
|
TraceWarning = 0x00000002,
|
|
|
|
TraceNotice = 0x00000003,
|
|
|
|
TraceInfo = 0x00000004,
|
|
|
|
TraceDebug = 0x00000005,
|
|
|
|
TraceVerbose = 0x00000006,
|
|
|
|
};
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2016-01-13 01:25:36 +00:00
|
|
|
#ifndef _WIN32
|
2016-01-12 19:02:18 +00:00
|
|
|
#define __interface struct
|
|
|
|
#endif
|
|
|
|
|
2015-12-14 10:51:33 +00:00
|
|
|
__interface CTraceModule
|
|
|
|
{
|
|
|
|
virtual void Write(uint32_t module, uint8_t severity, const char * file, int line, const char * function, const char * Message) = 0;
|
2008-09-18 03:15:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class CTraceFileLog : public CTraceModule
|
|
|
|
{
|
|
|
|
public:
|
2015-11-06 17:18:44 +00:00
|
|
|
CTraceFileLog(const char * FileName, bool FlushFile, LOG_OPEN_MODE eMode, size_t dwMaxFileSize = 5);
|
2015-12-10 06:38:33 +00:00
|
|
|
virtual ~CTraceFileLog();
|
2015-10-25 11:10:54 +00:00
|
|
|
|
2015-12-10 06:38:33 +00:00
|
|
|
void SetFlushFile(bool bFlushFile);
|
2015-12-14 10:51:33 +00:00
|
|
|
void Write(uint32_t module, uint8_t severity, const char * file, int line, const char * function, const char * Message);
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2015-12-14 10:51:33 +00:00
|
|
|
private:
|
|
|
|
CLog m_hLogFile;
|
|
|
|
bool m_FlushFile;
|
2008-09-18 03:15:49 +00:00
|
|
|
};
|
|
|
|
|
2015-12-14 10:51:33 +00:00
|
|
|
#define WriteTrace(m, s, format, ...) if(g_ModuleLogLevel[(m)] >= (s)) { WriteTraceFull((m), (s), __FILE__, __LINE__, __FUNCTION__, (format), ## __VA_ARGS__); }
|
|
|
|
|
|
|
|
CTraceModule * TraceAddModule(CTraceModule * TraceModule);
|
|
|
|
CTraceModule * TraceRemoveModule(CTraceModule * TraceModule);
|
|
|
|
const char * TraceSeverity(uint8_t severity);
|
|
|
|
const char * TraceModule(uint32_t module);
|
|
|
|
void TraceSetModuleName(uint8_t module, const char * Name);
|
|
|
|
void CloseTrace(void);
|
|
|
|
|
|
|
|
void WriteTraceFull(uint32_t module, uint8_t severity, const char * file, int line, const char * function, const char *format, ...);
|
|
|
|
void TraceSetMaxModule(uint32_t MaxModule, uint8_t DefaultSeverity);
|
|
|
|
|
|
|
|
extern uint32_t * g_ModuleLogLevel;
|