Lots and lots of whitespace and code style fixes

This commit is contained in:
2017-05-17 17:54:37 +03:00
parent 2442ceaee2
commit ff8546bf66
7 changed files with 191 additions and 180 deletions

32
log.c
View File

@@ -35,8 +35,8 @@ static void set_fpts(void)
fdout = stdout;
}
void log(LOG_LEVEL lvl, char *fmt, ... )
{
void log(enum LOG_LEVEL lvl, char *fmt, ...)
{
char fmt_with_pfx[1024];
pthread_once(&init_once, set_fpts);
@@ -45,31 +45,33 @@ void log(LOG_LEVEL lvl, char *fmt, ... )
if (lvl <= conf.rmps.loglevel) {
va_list list;
FILE *fp;
static const char *prefixes[] = {
static const char * const prefixes[] = {
"ERROR", "WARNING", "INFO", "VERBOSE"
};
time_t t = time(NULL);
struct tm tm;
localtime_r(&t, &tm);
if (lvl == ERROR || lvl == WARNING)
fp = fderr;
else
fp = fdout;
snprintf( fmt_with_pfx,
sizeof(fmt_with_pfx),
"[%d-%02d-%02d %02d:%02d:%02d] %s: %s\n",
tm.tm_year + 1900,
tm.tm_mon + 1,
tm.tm_mday,
tm.tm_hour,
tm.tm_min,
tm.tm_sec,
prefixes[lvl-1],
fmt );
snprintf(fmt_with_pfx,
sizeof(fmt_with_pfx),
"[%d-%02d-%02d %02d:%02d:%02d] %s: %s\n",
tm.tm_year + 1900,
tm.tm_mon + 1,
tm.tm_mday,
tm.tm_hour,
tm.tm_min,
tm.tm_sec,
prefixes[lvl-1],
fmt);
va_start(list, fmt);
vfprintf(fp, fmt_with_pfx, list);
va_end(list);
va_end(list);
}
}