-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogger.cpp
More file actions
42 lines (33 loc) · 762 Bytes
/
Logger.cpp
File metadata and controls
42 lines (33 loc) · 762 Bytes
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
#include <cstdio>
#include <sstream>
#include "Logger.h"
const std::string Logger::GetClassName(const char* name) const
{
std::string fullFilePath(name);
size_t lastSeparator = fullFilePath.find_last_of("/\\");
if (lastSeparator == std::string::npos)
{
return fullFilePath;
}
return fullFilePath.substr(lastSeparator + 1);
}
const std::string Logger::GetLogTypeMessage(const LogLevel& type) const
{
std::stringstream ss;
ss << className << ", line: " << line << std::endl;
const std::string msg = ss.str();
switch (type)
{
default:
case INFO:
return msg + "[INFO] ";
case DEBUG:
return msg + "[DEBUG] ";
case TRACE:
return msg + "[TRACE] ";
case WARNING:
return msg + "[WARNING] ";
case ERROR:
return msg + "[ERROR] ";
}
}