-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverLog.cpp
27 lines (24 loc) · 960 Bytes
/
serverLog.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
//
// Created by 神奇bug在哪里 on 2022/12/23.
//
#include "serverLog.h"
#include "settings.h"
enum log_level global_log_level = GLOBAL_LOG_LEVEL;
/*
* description: 以下函数均是用来日志输出的
* return: 无
*/
void log(enum log_level level, const std::string &context) {
if (level >= global_log_level) {
std::cout << (level == info ? INFO_COLOR : (level == warning ? WARNING_COLOR : ERROR_COLOR));
std::cout << (level == info ? "[I] " : (level == warning ? "[W] " : "[E] "));
std::cout << context << COLOR_END << std::endl;
}
}
void log(enum log_level level, const std::string &context, int id) {
if (level >= global_log_level) {
std::cout << (level == info ? INFO_COLOR : (level == warning ? WARNING_COLOR : ERROR_COLOR));
std::cout << (level == info ? "[I] " : (level == warning ? "[W] " : "[E] "));
std::cout << context << "\t[ID]: " << id << COLOR_END << std::endl;
}
}