From 09bd76f3a80eda63f21efd9cdca444ae72e65e14 Mon Sep 17 00:00:00 2001 From: Jessie Murray Date: Mon, 1 Mar 2021 18:17:38 -0800 Subject: [PATCH] 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.) --- src/slog.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/slog.c b/src/slog.c index 826a57e..1db7586 100644 --- a/src/slog.c +++ b/src/slog.c @@ -49,7 +49,7 @@ void slog(struct server *s, log_level level, const char *body, size_t sz) { - const char *c = ".-*#"; + const char *c = "EWNID"; time_t now; struct tm now_tm, *lt_ret; char time_buf[64]; @@ -77,7 +77,7 @@ slog(struct server *s, log_level level, /* generate output 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. */ ret = write(s->log.fd, line, line_sz);