|
|
@ -47,20 +47,37 @@ static void my_log_curses(int prio, const char *datetime, const char *str, bool |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* high-level logging function, based on global opt_log_level */ |
|
|
|
void applog(int prio, const char* fmt, ...) |
|
|
|
void applog(int prio, const char* fmt, ...) { |
|
|
|
{ |
|
|
|
|
|
|
|
va_list args; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
va_start(args, fmt); |
|
|
|
|
|
|
|
vapplogsiz(prio, LOGBUFSIZ, fmt, args); |
|
|
|
|
|
|
|
va_end(args); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void applogsiz(int prio, int size, const char* fmt, ...) |
|
|
|
|
|
|
|
{ |
|
|
|
va_list args; |
|
|
|
va_list args; |
|
|
|
|
|
|
|
|
|
|
|
if (opt_debug || prio != LOG_DEBUG) { |
|
|
|
|
|
|
|
if (use_syslog || opt_log_output || prio <= opt_log_level) { |
|
|
|
|
|
|
|
char tmp42[LOGBUFSIZ]; |
|
|
|
|
|
|
|
va_start(args, fmt); |
|
|
|
va_start(args, fmt); |
|
|
|
vsnprintf(tmp42, sizeof(tmp42), fmt, args); |
|
|
|
vapplogsiz(prio, size, fmt, args); |
|
|
|
va_end(args); |
|
|
|
va_end(args); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* high-level logging function, based on global opt_log_level */ |
|
|
|
|
|
|
|
void vapplogsiz(int prio, int size, const char* fmt, va_list args) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (opt_debug || prio != LOG_DEBUG) { |
|
|
|
|
|
|
|
if (use_syslog || opt_log_output || prio <= opt_log_level) { |
|
|
|
|
|
|
|
char *tmp42 = (char *)calloc(size, 1); |
|
|
|
|
|
|
|
vsnprintf(tmp42, size, fmt, args); |
|
|
|
_applog(prio, tmp42, false); |
|
|
|
_applog(prio, tmp42, false); |
|
|
|
|
|
|
|
free(tmp42); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* log function |
|
|
|
* log function |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -84,8 +101,7 @@ void _applog(int prio, const char *str, bool force) |
|
|
|
tm = localtime(&tmp_time); |
|
|
|
tm = localtime(&tmp_time); |
|
|
|
|
|
|
|
|
|
|
|
/* Day changed. */ |
|
|
|
/* Day changed. */ |
|
|
|
if (opt_log_show_date && (last_date_output_day != tm->tm_mday)) |
|
|
|
if (opt_log_show_date && (last_date_output_day != tm->tm_mday)) { |
|
|
|
{ |
|
|
|
|
|
|
|
last_date_output_day = tm->tm_mday; |
|
|
|
last_date_output_day = tm->tm_mday; |
|
|
|
char date_output_str[64]; |
|
|
|
char date_output_str[64]; |
|
|
|
snprintf(date_output_str, sizeof(date_output_str), "Log date is now %d-%02d-%02d", |
|
|
|
snprintf(date_output_str, sizeof(date_output_str), "Log date is now %d-%02d-%02d", |
|
|
@ -93,11 +109,9 @@ void _applog(int prio, const char *str, bool force) |
|
|
|
tm->tm_mon + 1, |
|
|
|
tm->tm_mon + 1, |
|
|
|
tm->tm_mday); |
|
|
|
tm->tm_mday); |
|
|
|
_applog(prio, date_output_str, force); |
|
|
|
_applog(prio, date_output_str, force); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (opt_log_show_date) |
|
|
|
if (opt_log_show_date) { |
|
|
|
{ |
|
|
|
|
|
|
|
snprintf(datetime, sizeof(datetime), "[%d-%02d-%02d %02d:%02d:%02d] ", |
|
|
|
snprintf(datetime, sizeof(datetime), "[%d-%02d-%02d %02d:%02d:%02d] ", |
|
|
|
tm->tm_year + 1900, |
|
|
|
tm->tm_year + 1900, |
|
|
|
tm->tm_mon + 1, |
|
|
|
tm->tm_mon + 1, |
|
|
@ -106,8 +120,7 @@ void _applog(int prio, const char *str, bool force) |
|
|
|
tm->tm_min, |
|
|
|
tm->tm_min, |
|
|
|
tm->tm_sec); |
|
|
|
tm->tm_sec); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else { |
|
|
|
{ |
|
|
|
|
|
|
|
snprintf(datetime, sizeof(datetime), "[%02d:%02d:%02d] ", |
|
|
|
snprintf(datetime, sizeof(datetime), "[%02d:%02d:%02d] ", |
|
|
|
tm->tm_hour, |
|
|
|
tm->tm_hour, |
|
|
|
tm->tm_min, |
|
|
|
tm->tm_min, |
|
|
|