-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathLogSystem.h
62 lines (50 loc) · 1.52 KB
/
LogSystem.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#pragma once
#include "CompileEnvironment.h"
namespace Scan
{
struct ILogFile
{
virtual ~ILogFile() = 0 {}
virtual void log(const char* msg, const char *file, int line, const char *func) = 0;
virtual void close() = 0;
};
class LogFile_Console:
public ILogFile
{
public:
LogFile_Console(){}
virtual void log(const char* msg, const char *file, int line, const char *func);
virtual void close();
private:
LogFile_Console(const LogFile_Console&);
LogFile_Console& operator = (const LogFile_Console&);
};
class LogFile_VCDebug:
public ILogFile
{
public:
LogFile_VCDebug(){}
virtual void log(const char* msg, const char *file, int line, const char *func);
virtual void close();
private:
LogFile_VCDebug(const LogFile_VCDebug&);
LogFile_VCDebug& operator = (const LogFile_VCDebug&);
};
class Logger
{
public:
Logger(ILogFile *logFile, bool isAutoDeleteFile = true);
~Logger(void);
void log(const char *msg, const char *file, int line, const char *func);
private:
Logger(const Logger&);
Logger& operator = (const Logger&);
private:
bool m_isAutoDeleteFile;
ILogFile *m_logFile;
};
Logger* getConsoleLogger();
Logger* getVCDebugLogger();
#define SCAN_LOG(msg) getVCDebugLogger()->log(msg, __FILE__, __LINE__, __FUNCTION)
#define SCAN_LOG_ASSERT(b, msg) if (!b) { LOG(msg); } else {}
}