slog.c: Change level symbol to a single letter

A single symbol was added to the log depending on the level, one of ".-*#"
This had an issue: there were only 4 symbols but there are 5 levels; in
addition a `%b` was used which logged a number instead of a letter.
This commit changes the logic to add a single uppercase letter instead,
based on the level (e.g. WEBDIS_ERROR is E, _INFO is I, etc.)
master
Jessie Murray 4 years ago committed by Nicolas Favre-Felix
parent 02d60dc548
commit 09bd76f3a8

@ -49,7 +49,7 @@ void
slog(struct server *s, log_level level, slog(struct server *s, log_level level,
const char *body, size_t sz) { const char *body, size_t sz) {
const char *c = ".-*#"; const char *c = "EWNID";
time_t now; time_t now;
struct tm now_tm, *lt_ret; struct tm now_tm, *lt_ret;
char time_buf[64]; char time_buf[64];
@ -77,7 +77,7 @@ slog(struct server *s, log_level level,
/* generate output line. */ /* generate output line. */
line_sz = snprintf(line, sizeof(line), line_sz = snprintf(line, sizeof(line),
"[%d] %s %d %s\n", (int)s->log.self, time_buf, c[level], msg); "[%d] %s %c %s\n", (int)s->log.self, time_buf, c[level], msg);
/* write to log and flush to disk. */ /* write to log and flush to disk. */
ret = write(s->log.fd, line, line_sz); ret = write(s->log.fd, line, line_sz);

Loading…
Cancel
Save