|
|
@ -7,6 +7,8 @@ |
|
|
|
|
|
|
|
|
|
|
|
#define LOGLINE_MAX 1024 |
|
|
|
#define LOGLINE_MAX 1024 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static log_msgtype_t minlevel = log_info; |
|
|
|
|
|
|
|
|
|
|
|
static const char *loglevels[] = { |
|
|
|
static const char *loglevels[] = { |
|
|
|
"debug", |
|
|
|
"debug", |
|
|
|
"info", |
|
|
|
"info", |
|
|
@ -15,11 +17,14 @@ static const char *loglevels[] = { |
|
|
|
"fatal", |
|
|
|
"fatal", |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
void log_msg(log_msgtype_t l, const char *fmt, ...) { |
|
|
|
void f2b_log_msg(log_msgtype_t l, const char *fmt, ...) { |
|
|
|
va_list args; |
|
|
|
va_list args; |
|
|
|
char line[LOGLINE_MAX] = ""; |
|
|
|
char line[LOGLINE_MAX] = ""; |
|
|
|
char msg[LOGLINE_MAX] = ""; |
|
|
|
char msg[LOGLINE_MAX] = ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (l < minlevel) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
va_start(args, fmt); |
|
|
|
va_start(args, fmt); |
|
|
|
snprintf(msg, sizeof(msg), fmt, args); |
|
|
|
snprintf(msg, sizeof(msg), fmt, args); |
|
|
|
va_end(args); |
|
|
|
va_end(args); |
|
|
@ -27,3 +32,11 @@ void log_msg(log_msgtype_t l, const char *fmt, ...) { |
|
|
|
|
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void f2b_log_set_level(const char *level) { |
|
|
|
|
|
|
|
if (strcmp(level, "debug") == 0) { minlevel = log_debug; return; } |
|
|
|
|
|
|
|
if (strcmp(level, "info") == 0) { minlevel = log_info; return; } |
|
|
|
|
|
|
|
if (strcmp(level, "warn") == 0) { minlevel = log_warn; return; } |
|
|
|
|
|
|
|
if (strcmp(level, "error") == 0) { minlevel = log_error; return; } |
|
|
|
|
|
|
|
if (strcmp(level, "fatal") == 0) { minlevel = log_fatal; return; } |
|
|
|
|
|
|
|
} |
|
|
|