diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-05-15 19:12:09 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-05-15 19:12:09 +0200 |
commit | 79c0d7332ab9707bcbdaaa71b034d939ad36c8d7 (patch) | |
tree | 469f2a7d769ccd92bccfa61d47793a82d1ef29b3 | |
parent | ed820ccda1a2323b5821db637ccd6dbb3dfce340 (diff) | |
download | busybox-w32-79c0d7332ab9707bcbdaaa71b034d939ad36c8d7.tar.gz busybox-w32-79c0d7332ab9707bcbdaaa71b034d939ad36c8d7.tar.bz2 busybox-w32-79c0d7332ab9707bcbdaaa71b034d939ad36c8d7.zip |
svlogd.c: support -ttt (dateTtime instead of date_time)
Backport from upstream version:
1.7.0
Sat, 07 Oct 2006 18:24:17 +0000
* svlogd.c: new option -ttt: prefix log messages with sortable UTC
timestamp YYYY-MM-DDTHH:MM:SS.xxxxx.
function old new delta
svlogd_main 1429 1454 +25
packed_usage 31575 31580 +5
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | runit/svlogd.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/runit/svlogd.c b/runit/svlogd.c index 3ed13b67b..795bf48bb 100644 --- a/runit/svlogd.c +++ b/runit/svlogd.c | |||
@@ -137,9 +137,9 @@ log message, you can use a pattern like this instead | |||
137 | //kbuild:lib-$(CONFIG_SVLOGD) += svlogd.o | 137 | //kbuild:lib-$(CONFIG_SVLOGD) += svlogd.o |
138 | 138 | ||
139 | //usage:#define svlogd_trivial_usage | 139 | //usage:#define svlogd_trivial_usage |
140 | //usage: "[-ttv] [-r C] [-R CHARS] [-l MATCHLEN] [-b BUFLEN] DIR..." | 140 | //usage: "[-tttv] [-r C] [-R CHARS] [-l MATCHLEN] [-b BUFLEN] DIR..." |
141 | //usage:#define svlogd_full_usage "\n\n" | 141 | //usage:#define svlogd_full_usage "\n\n" |
142 | //usage: "Continuously read log data from stdin and write to rotated log files in DIRs" | 142 | //usage: "Read log data from stdin and write to rotated log files in DIRs" |
143 | //usage: "\n" | 143 | //usage: "\n" |
144 | //usage: "\n""DIR/config file modifies behavior:" | 144 | //usage: "\n""DIR/config file modifies behavior:" |
145 | //usage: "\n""sSIZE - when to rotate logs" | 145 | //usage: "\n""sSIZE - when to rotate logs" |
@@ -339,17 +339,18 @@ static unsigned pmatch(const char *p, const char *s, unsigned len) | |||
339 | /*** ex fmt_ptime.[ch] ***/ | 339 | /*** ex fmt_ptime.[ch] ***/ |
340 | 340 | ||
341 | /* NUL terminated */ | 341 | /* NUL terminated */ |
342 | static void fmt_time_human_30nul(char *s) | 342 | static void fmt_time_human_30nul(char *s, char dt_delim) |
343 | { | 343 | { |
344 | struct tm *ptm; | 344 | struct tm *ptm; |
345 | struct timeval tv; | 345 | struct timeval tv; |
346 | 346 | ||
347 | gettimeofday(&tv, NULL); | 347 | gettimeofday(&tv, NULL); |
348 | ptm = gmtime(&tv.tv_sec); | 348 | ptm = gmtime(&tv.tv_sec); |
349 | sprintf(s, "%04u-%02u-%02u_%02u:%02u:%02u.%06u000", | 349 | sprintf(s, "%04u-%02u-%02u%c%02u:%02u:%02u.%06u000", |
350 | (unsigned)(1900 + ptm->tm_year), | 350 | (unsigned)(1900 + ptm->tm_year), |
351 | (unsigned)(ptm->tm_mon + 1), | 351 | (unsigned)(ptm->tm_mon + 1), |
352 | (unsigned)(ptm->tm_mday), | 352 | (unsigned)(ptm->tm_mday), |
353 | dt_delim, | ||
353 | (unsigned)(ptm->tm_hour), | 354 | (unsigned)(ptm->tm_hour), |
354 | (unsigned)(ptm->tm_min), | 355 | (unsigned)(ptm->tm_min), |
355 | (unsigned)(ptm->tm_sec), | 356 | (unsigned)(ptm->tm_sec), |
@@ -1160,8 +1161,8 @@ int svlogd_main(int argc, char **argv) | |||
1160 | if (timestamp) { | 1161 | if (timestamp) { |
1161 | if (timestamp == 1) | 1162 | if (timestamp == 1) |
1162 | fmt_time_bernstein_25(stamp); | 1163 | fmt_time_bernstein_25(stamp); |
1163 | else /* 2: */ | 1164 | else /* 2+: */ |
1164 | fmt_time_human_30nul(stamp); | 1165 | fmt_time_human_30nul(stamp, timestamp == 2 ? '_' : 'T'); |
1165 | printlen += 26; | 1166 | printlen += 26; |
1166 | printptr -= 26; | 1167 | printptr -= 26; |
1167 | memcpy(printptr, stamp, 25); | 1168 | memcpy(printptr, stamp, 25); |