Use thread-safe localtime and tweak loglevel

This commit is contained in:
2016-08-09 15:02:16 +03:00
parent 3fecfdbbc4
commit 0c4a57faed
3 changed files with 8 additions and 6 deletions

View File

@@ -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;