forked from Splitx12/MrMeow-dev-release-based-SOT-Hook-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogger.cpp
93 lines (85 loc) · 1.62 KB
/
logger.cpp
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include "logger.h"
bool tslog::init(level _logLevel, bool showConsole)
{
logLevel = _logLevel;
bShowConsole = showConsole;
if (logLevel < level::OFF)
{
if (bShowConsole)
if (AllocConsole())
freopen_s(&file, "CONOUT$", "w", stdout);
else
bShowConsole = false;
}
return true;
}
bool tslog::shutdown()
{
log("Closing logger...");
if (logLevel >= level::OFF)
return true;
Sleep(5000);
if (bShowConsole && file != NULL)
{
fclose(file);
FreeConsole();
}
return true;
}
void tslog::debug(const char* text, ...)
{
#if not PRINT_DEBUG_LOGS
return;
#endif
if (logLevel < level::OFF)
if (bShowConsole)
{
char buffer[256];
va_buffer(args, text, buffer);
std::cout << "[DEBUG]: " << buffer << std::endl;
}
}
void tslog::critical(const char* text, ...)
{
if (logLevel <= level::CRITICAL)
if (bShowConsole)
{
char buffer[256];
va_buffer(args, text, buffer);
std::cout << "[CRITICAL]: " << buffer << std::endl;
}
}
void tslog::info(const char* text, ...)
{
if (logLevel <= level::INFO)
if (bShowConsole)
{
char buffer[256];
va_buffer(args, text, buffer);
std::cout << "[INFO]: " << buffer << std::endl;
}
}
void tslog::log(const char* text, ...)
{
if (logLevel <= level::LOG)
if (bShowConsole)
{
char buffer[256];
va_buffer(args, text, buffer);
std::cout << "[LOG]: " << buffer << std::endl;
}
}
void tslog::verbose(const char* text, ...)
{
if (logLevel <= level::VERBOSE)
if (bShowConsole)
{
char buffer[256];
va_buffer(args, text, buffer);
std::cout << "[VERBOSE]: " << buffer << std::endl;
}
}
bool tslog::setLevel(int level)
{
return true;
}