-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogManager.h
More file actions
77 lines (61 loc) · 1.48 KB
/
LogManager.h
File metadata and controls
77 lines (61 loc) · 1.48 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#ifndef LOGGING_H
#define LOGGING_H
#include <string>
#include <fstream>
#include <Windows.h>
#include <sstream>
#include <iostream>
namespace Log {
enum {
COLOR_BLACK,
COLOR_BLUE,
COLOR_GREEN,
COLOR_AQUA,
COLOR_RED,
COLOR_PURPLE,
COLOR_YELLOW,
COLOR_WHITE,
COLOR_GRAY,
COLOR_LIGHT_BLUE,
COLOR_LIGHT_GREEN,
COLOR_LIGHT_AQUA,
COLOR_LIGHT_RED,
COLOR_LIGHT_PURPLE,
COLOR_LIGHT_YELLOW,
COLOR_LIGHT_WHITE
};
const static int COLOR_DEFAULT = COLOR_LIGHT_WHITE;
const static int COLOR_ERROR = COLOR_LIGHT_RED;
const static int COLOR_WARNING = COLOR_LIGHT_YELLOW;
const static int COLOR_SUCCESS = COLOR_LIGHT_GREEN;
bool Write(std::string text, int color = Log::COLOR_DEFAULT);
bool Writeln(std::string text, int color = Log::COLOR_DEFAULT);
bool Warn(std::string warn);
bool Err(std::string err);
bool Success(std::string msg);
}
class LogManager {
public:
~LogManager();
static LogManager& GetInstance(){ return m_instance; }
bool Write(std::string text, int color);
private:
LogManager();
LogManager(const LogManager&);
void operator=(const LogManager&);
std::string m_logFilePath;
std::string m_logFileName;
std::ofstream* m_logFile;
void* m_hstdout;
bool bDisableFile;
static LogManager m_instance;
std::ofstream* m_xFile;
void WriteCmd(std::string text, int color);
bool WriteFile(std::string text);
std::string GenerateFileName();
bool OpenFile();
bool FileOpen();
void CloseFile();
void VerifyLogPath();
};
#endif