From f69d4707527da8c48e93cb49f85c71c890ae8edd Mon Sep 17 00:00:00 2001 From: Valentin Bartenev Date: Tue, 21 Jul 2020 20:27:37 +0300 Subject: [PATCH] Fixed non-debug log time format in libunit. This makes log format used in libunit consistent with the daemon, where milliseconds are printed only in the debug log level. Currently a compile time switch is used, since there's no support for runtime changing of a log level for now. But in the future this should be a runtime condition, similar to nxt_log_time_handler(). --- src/nxt_unit.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/nxt_unit.c b/src/nxt_unit.c index 9f6eab95..89998e3f 100644 --- a/src/nxt_unit.c +++ b/src/nxt_unit.c @@ -4977,11 +4977,18 @@ nxt_unit_snprint_prefix(char *p, char *end, pid_t pid, int level) tm = *localtime(&ts.tv_sec); #endif +#if (NXT_DEBUG) p += snprintf(p, end - p, "%4d/%02d/%02d %02d:%02d:%02d.%03d ", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, (int) ts.tv_nsec / 1000000); +#else + p += snprintf(p, end - p, + "%4d/%02d/%02d %02d:%02d:%02d ", + tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, + tm.tm_hour, tm.tm_min, tm.tm_sec); +#endif p += snprintf(p, end - p, "[%s] %d#%"PRIu64" [unit] ", nxt_unit_log_levels[level],