diff options
author | Valentin Bartenev <vbart@nginx.com> | 2020-07-21 20:27:37 +0300 |
---|---|---|
committer | Valentin Bartenev <vbart@nginx.com> | 2020-07-21 20:27:37 +0300 |
commit | f69d4707527da8c48e93cb49f85c71c890ae8edd (patch) | |
tree | feb01bc0d8606f79cc16780054a8c232841a0e7d /src/nxt_unit.c | |
parent | 55bac9153b5e5d62cf7beab4cf53b3cec33ea8df (diff) | |
download | unit-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.c | 7 |
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], |