summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_unit.c
diff options
context:
space:
mode:
authorValentin Bartenev <vbart@nginx.com>2020-07-21 20:27:37 +0300
committerValentin Bartenev <vbart@nginx.com>2020-07-21 20:27:37 +0300
commitf69d4707527da8c48e93cb49f85c71c890ae8edd (patch)
treefeb01bc0d8606f79cc16780054a8c232841a0e7d /src/nxt_unit.c
parent55bac9153b5e5d62cf7beab4cf53b3cec33ea8df (diff)
downloadunit-f69d4707527da8c48e93cb49f85c71c890ae8edd.tar.gz
unit-f69d4707527da8c48e93cb49f85c71c890ae8edd.tar.bz2
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().
Diffstat (limited to 'src/nxt_unit.c')
-rw-r--r--src/nxt_unit.c7
1 files changed, 7 insertions, 0 deletions
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],