-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogger.cpp
More file actions
35 lines (31 loc) · 752 Bytes
/
Copy pathLogger.cpp
File metadata and controls
35 lines (31 loc) · 752 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
#include "Logger.h"
#include "Timestamp.h"
#include <iostream>
Logger& Logger::getInstance() {
static Logger logger;
return logger;
}
void Logger::setLevel(Level level) {
level_ = level;
}
// [级别信息] 时间戳 : msg
void Logger::log(const std::string& msg) {
std::string pre = "";
switch(level_) {
case Level::INFO:
pre = "[INFO]";
break;
case Level::DEBUG:
pre = "[DEBUG]";
break;
case Level::ERROR:
pre = "[ERROR]";
break;
case Level::FATAL:
pre = "[FATAL]";
break;
default:
break;
}
std::cout << pre + Timestamp::now().toString() << " : " << msg << std::endl;
}