-
Notifications
You must be signed in to change notification settings - Fork 0
/
logger.cpp
62 lines (51 loc) · 1.62 KB
/
logger.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "logger.h"
logger *logger::singleton_instance=NULL;
logger::logger(const std::string& log_mode, const unsigned char& error_level, const std::string& error_level_filter){
this->log_mode=log_mode;
this->error_level=error_level;
if(error_level_filter=="LT"||error_level_filter=="LE"||error_level_filter=="EQ"||error_level_filter=="GE"||error_level_filter=="GT"){
this->error_level_filter=error_level_filter;
}
else this->error_level_filter="LE";
}
logger::~logger(){
logger::singleton()==NULL?(void)0:logger::singleton()->log(3,"destructing logger");
logger::singleton_instance=NULL;
}
void logger::log(const unsigned char& error_level, const std::string& message){
if(log_mode=="console"){
if(error_level_filter=="LT"){
}
else if(error_level_filter=="LE"){
if(error_level<=this->error_level){
#ifdef __ANDROID__
if(error_level==0){
__android_log_print(ANDROID_LOG_INFO, "hi", "%s", message.c_str());
}
else if(error_level==1){
__android_log_print(ANDROID_LOG_WARN, "hi", "%s", message.c_str());
}
else if(error_level==2){
__android_log_print(ANDROID_LOG_ERROR, "hi", "%s", message.c_str());
}
else if(error_level==3){
__android_log_print(ANDROID_LOG_DEBUG, "hi", "%s", message.c_str());
}
else{
__android_log_print(ANDROID_LOG_INFO, "hi", "%s", message.c_str());
}
#else
std::cout<<message<<std::endl;
#endif
}
}
else if(error_level_filter=="EQ"){
}
else if(error_level_filter=="GE"){
}
else if(error_level_filter=="GT"){
}
else{
}
}
}