Show log level

This commit is contained in:
Sergey Lyubka 2021-09-13 13:48:02 +01:00
parent dca08d32bd
commit 6316609a5f
2 changed files with 6 additions and 8 deletions

View File

@ -1832,11 +1832,10 @@ bool mg_log_prefix(int level, const char *file, int line, const char *fname) {
char timebuf[21], buf[50] = "";
time_t t = time(NULL);
struct tm tmp, *tm = gmtime_r(&t, &tmp);
int n, tag;
(void)tmp;
int n;
(void) tmp;
strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S", tm);
tag = level == LL_ERROR ? 'E' : level == LL_INFO ? 'I' : ' ';
n = snprintf(buf, sizeof(buf), "%s %c %s:%d:%s", timebuf, tag, p, line,
n = snprintf(buf, sizeof(buf), "%s %d %s:%d:%s", timebuf, level, p, line,
fname);
if (n < 0 || n > (int) sizeof(buf) - 2) n = sizeof(buf) - 2;
while (n < (int) sizeof(buf) - 1) buf[n++] = ' ';

View File

@ -36,11 +36,10 @@ bool mg_log_prefix(int level, const char *file, int line, const char *fname) {
char timebuf[21], buf[50] = "";
time_t t = time(NULL);
struct tm tmp, *tm = gmtime_r(&t, &tmp);
int n, tag;
(void)tmp;
int n;
(void) tmp;
strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S", tm);
tag = level == LL_ERROR ? 'E' : level == LL_INFO ? 'I' : ' ';
n = snprintf(buf, sizeof(buf), "%s %c %s:%d:%s", timebuf, tag, p, line,
n = snprintf(buf, sizeof(buf), "%s %d %s:%d:%s", timebuf, level, p, line,
fname);
if (n < 0 || n > (int) sizeof(buf) - 2) n = sizeof(buf) - 2;
while (n < (int) sizeof(buf) - 1) buf[n++] = ' ';