158:77f4f0079428 | 166:c07122f66676 |
---|---|
82 "config", | 82 "config", |
83 "security", | 83 "security", |
84 "failure", | 84 "failure", |
85 "catastrophe", | 85 "catastrophe", |
86 "info", | 86 "info", |
87 "verbose" | 87 "verbose", |
88 "debug" | |
88 }; | 89 }; |
89 | 90 |
90 static int can_log[] = { | 91 static int can_log[] = { |
91 1, // warning | 92 1, // warning |
92 1, // config | 93 1, // config |
93 1, // security | 94 1, // security |
94 1, // failure | 95 1, // failure |
95 1, // catastrophe | 96 1, // catastrophe |
96 1, // info | 97 1, // info |
97 0 // verbose | 98 0, // verbose |
99 0 // debug | |
98 }; | 100 }; |
99 | 101 |
100 int init_log_file(LogConfig *cfg) { | 102 int init_log_file(LogConfig *cfg) { |
101 if(is_initialized) { | 103 if(is_initialized) { |
102 return 0; | 104 return 0; |
112 if(!strcmp(cfg->level, "ERROR")) { | 114 if(!strcmp(cfg->level, "ERROR")) { |
113 can_log[LOG_WARN] = 0; | 115 can_log[LOG_WARN] = 0; |
114 can_log[LOG_INFORM] = 0; | 116 can_log[LOG_INFORM] = 0; |
115 } else if(!strcmp(cfg->level, "WARNING")) { | 117 } else if(!strcmp(cfg->level, "WARNING")) { |
116 can_log[LOG_INFORM] = 0; | 118 can_log[LOG_INFORM] = 0; |
117 } else if(!strcmp(cfg->level, "INFO")) { | |
118 | |
119 } else if(!strcmp(cfg->level, "VERBOSE")) { | 119 } else if(!strcmp(cfg->level, "VERBOSE")) { |
120 can_log[LOG_VERBOSE] = 1; | 120 can_log[LOG_VERBOSE] = 1; |
121 } else if(!strcmp(cfg->level, "DEBUG")) { | |
122 can_log[LOG_VERBOSE] = 1; | |
123 can_log[LOG_DEBUG] = 1; | |
121 } | 124 } |
122 | 125 |
123 if(cfg->log_stdout) { | 126 if(cfg->log_stdout) { |
124 // TODO | 127 // TODO |
125 } | 128 } |
223 va_end(args); | 226 va_end(args); |
224 return ret; | 227 return ret; |
225 } | 228 } |
226 | 229 |
227 int log_ereport_v(int degree, const char *format, va_list args) { | 230 int log_ereport_v(int degree, const char *format, va_list args) { |
228 if(degree > 6) { | 231 if(degree < 0 || degree > 7) { |
229 return 0; | 232 return 0; |
230 } | 233 } |
231 if(degree > 0 && !can_log[degree]) { | 234 if(!can_log[degree]) { |
232 return 0; | 235 return 0; |
233 } | 236 } |
234 | 237 |
235 sstr_t lmsg; | 238 sstr_t lmsg; |
236 lmsg.ptr = NULL; | 239 lmsg.ptr = NULL; |