Skip to content

Commit 8ea66dd

Browse files
committed
[generic_log] nanosecond-precision timestamps
1 parent 19e0340 commit 8ea66dd

4 files changed

Lines changed: 11 additions & 1 deletion

File tree

src/log_format_impls.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class generic_log_format : public log_format {
148148
static const pcre_format log_fmt[] = {
149149
pcre_format(R"(^(?:\*\*\*\s+)?(?<timestamp>@[0-9a-zA-Z]{16,24}))"),
150150
pcre_format(
151-
R"(^(?:\*\*\*\s+)?(?<timestamp>(?:\s|\d{4}[\-\/]\d{2}[\-\/]\d{2}|T|\d{1,2}:\d{2}(?::\d{2}(?:[\.,]\d{1,6})?)?|Z|[+\-]\d{2}:?\d{2}|(?!DBG|DEBUG|ERR|INFO|WARN|NONE)[A-Z]{3,4})+)[:|\s]?(trc|trace|dbg|debug|info|warn(?:ing)?|err(?:or)?)[:|\s]\s*)"),
151+
R"(^(?:\*\*\*\s+)?(?<timestamp>(?:\s|\d{4}[\-\/]\d{2}[\-\/]\d{2}|T|\d{1,2}:\d{2}(?::\d{2}(?:[\.,]\d{1,9})?)?|Z|[+\-]\d{2}:?\d{2}|(?!DBG|DEBUG|ERR|INFO|WARN|NONE)[A-Z]{3,4})+)[:|\s]?(trc|trace|dbg|debug|info|warn(?:ing)?|err(?:or)?)[:|\s]\s*)"),
152152
pcre_format(
153153
R"(^(?:\*\*\*\s+)?(?<timestamp>[\w:+ \.,+/-]+) \[(trace|debug|info|warn(?:ing)?|error|critical)\]\s+)"),
154154
pcre_format(

test/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ dist_noinst_DATA = \
364364
logfile_generic.1 \
365365
logfile_generic.2 \
366366
logfile_generic.3 \
367+
logfile_generic_nanos.0 \
367368
logfile_generic_with_header.0 \
368369
logfile_glog.0 \
369370
logfile_grafana.0 \

test/logfile_generic_nanos.0

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2025-01-01 00:00:00.123456789:INFO:nano first
2+
2025-01-01 01:00:00.987654321:WARN:nano second

test/test_logfile.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,13 @@ Jul 02 10:22:40 2012 -- 672
548548
Oct 08 16:56:38 2014 -- 344
549549
EOF
550550

551+
run_test ./drive_logfile -t -f generic_log ${srcdir}/logfile_generic_nanos.0
552+
553+
check_output "generic_log nanosecond timestamp not parsed?" <<EOF
554+
Jan 01 00:00:00 2025 -- 123
555+
Jan 01 01:00:00 2025 -- 987
556+
EOF
557+
551558
run_test ./drive_logfile -v -f generic_log ${srcdir}/logfile_generic.0
552559

553560
check_output "generic_log level interpreted incorrectly?" <<EOF

0 commit comments

Comments
 (0)