Use thread-safe localtime and tweak loglevel
This commit is contained in:
@@ -33,21 +33,21 @@ static void set_fpts(void)
|
||||
|
||||
void log_trace(LOG_LEVEL lvl, char *fmt, ... )
|
||||
{
|
||||
LOG_LEVEL cur_lvl = conf.rmps.loglevel - '0';
|
||||
char fmt_with_pfx[1024];
|
||||
|
||||
pthread_once(&init_once, set_fpts);
|
||||
if (conf.isvalid)
|
||||
pthread_once(&once, open_logs);
|
||||
if (lvl <= cur_lvl) {
|
||||
if (lvl <= conf.rmps.loglevel) {
|
||||
va_list list;
|
||||
FILE *fp;
|
||||
static const char *prefixes[] = {
|
||||
"ERROR", "WARNING", "INFO", "VERBOSE"
|
||||
};
|
||||
time_t t = time(NULL);
|
||||
struct tm tm = *localtime(&t);
|
||||
if (lvl == ERROR || lvl == WARNING)
|
||||
struct tm tm;
|
||||
localtime_r(&t, &tm);
|
||||
if (conf.rmps.loglevel == ERROR || conf.rmps.loglevel == WARNING)
|
||||
fp = fderr;
|
||||
else
|
||||
fp = fdout;
|
||||
|
||||
Reference in New Issue
Block a user