240717班级,工业化控制系统,煤矿相关行业,昆仑系统
wangky
2024-11-07 04755abc587b8690115b00affb8251ddbc10610e
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
#include <iostream>
#include "log.h"
 
int main() {
    // 初始化日志系统
    if (!Log::get_instance()->init("test_log.txt", 0, 8192, 5000000, 1000)) {
        std::cerr << "Failed to initialize log system." << std::endl;
        return 1;
    }
 
    // 测试写入不同级别的日志
    Log::get_instance()->write_log(DEBUG, "This is a debug message.");
    Log::get_instance()->write_log(INFO, "This is an info message.");
    Log::get_instance()->write_log(WARN, "This is a warning message.");
    Log::get_instance()->write_log(ERROR, "This is an error message.");
 
    // 模拟接收原始日志
    Log::get_instance()->receiveLog("[info]: Device123 Operation successful.");
 
    // 刷新日志
    Log::get_instance()->flush();
 
    std::cout << "Logs written successfully." << std::endl;
    return 0;
}