-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBaseLogger.cpp
executable file
·70 lines (66 loc) · 2.3 KB
/
BaseLogger.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
#include "BaseLogger.h"
BaseLogger::BaseLogger(void)
{
}
BaseLogger::~BaseLogger(void)
{
}
E_LOG_TYPE BaseLogger::GetLogType()
{
return m_LogType;
}
void BaseLogger::LogDebug(const char * info, const char * file, const unsigned long line, const char * function)
{
Log(LOG_LEVEL_DEBUG, info, file, line, function);
}
void BaseLogger::LogInfo(const char * info, const char * file, const unsigned long line, const char * function)
{
Log(LOG_LEVEL_INFO, info, file, line, function);
}
void BaseLogger::LogNotice(const char * info, const char * file, const unsigned long line, const char * function)
{
Log(LOG_LEVEL_NOTICE, info, file, line, function);
}
void BaseLogger::LogWarn(const char * info, const char * file, const unsigned long line, const char * function)
{
Log(LOG_LEVEL_WARN, info, file, line, function);
}
void BaseLogger::LogError(const char * info, const char * file, const unsigned long line, const char * function)
{
Log(LOG_LEVEL_ERROR, info, file, line, function);
}
void BaseLogger::LogCrit(const char * info, const char * file, const unsigned long line, const char * function)
{
Log(LOG_LEVEL_CRIT, info, file, line, function);
}
void BaseLogger::LogAlert(const char * info, const char * file, const unsigned long line, const char * function)
{
Log(LOG_LEVEL_ALERT, info, file, line, function);
}
void BaseLogger::LogEmerg(const char * info, const char * file, const unsigned long line, const char * function)
{
Log(LOG_LEVEL_EMERG, info, file, line, function);
}
const char * BaseLogger::GetSystemTime(const char * format)
{
time_t rawtime;
time(&rawtime);
#ifdef WIN32
struct tm timeinfo;
localtime_s(&timeinfo, &rawtime);
sprintf_s(
m_CurrentTime, sizeof(m_CurrentTime),
format,
1900 + timeinfo.tm_year, 1 + timeinfo.tm_mon, timeinfo.tm_mday, timeinfo.tm_hour, timeinfo.tm_min, timeinfo.tm_sec);
#else
struct tm *timeinfo;
timeinfo = localtime(&rawtime);
snprintf(
m_CurrentTime, sizeof(m_CurrentTime),
format,
1900 + timeinfo->tm_year, 1 + timeinfo->tm_mon, timeinfo->tm_mday, timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
#endif
return m_CurrentTime;
}
const char* BaseLogger::LEVEL_STRING[] = {"EMERG","ALERT","CRIT","ERROR","WARN","NOTICE","INFO","DEBUG"};
char BaseLogger::m_CurrentTime[] = "\0";