-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain.cpp
More file actions
30 lines (28 loc) · 985 Bytes
/
main.cpp
File metadata and controls
30 lines (28 loc) · 985 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
#include <thread>
#include <chrono>
#include <stdio.h>
#include <iostream>
#include "log/logging.h"
int main(void){
printf("logger examples:");
// 最先初始化log
if (!logger::init("logs","test")) { // 初始化,设置日志保存路径为logs, log文件的名字为test
printf("[ERROR]logger init failed!\n");
return 1;
}
else
printf("[INFO]logger init succeed!\n");
while(1){ // 死循环里,1比true更高效
logger_debug << "\tHello World!";
logger_trace << "\tHello World!";
logger_info << "\tHello World!";
logger_warning << "\tHello World!";
logger_fatal << "\tHello World!";
logger_error << "\tHello World!";
logger::update_rotation_time(); // 更新日志切割时间(这里的切割逻辑是20点之后算新的一天),如果不想切割不调用即可
std::this_thread::sleep_for(std::chrono::milliseconds(200));
}
// 后处理
logger::stop();
return 0;
}