mirror of
https://github.com/tstack/lnav.git
synced 2024-08-16 16:30:25 +03:00
parent
a4deaa1e8b
commit
5ea5504aec
@ -308,9 +308,9 @@ void log_format::check_for_new_year(std::vector<logline> &dst, exttm etm,
|
||||
}
|
||||
if (diff > (60 * 24 * 60 * 60)) {
|
||||
off_year = 1;
|
||||
} else if (diff > (15 * 24 * 60 * 60)) {
|
||||
} else if (diff >= (24 * 60 * 60)) {
|
||||
off_month = 1;
|
||||
} else if (diff > (12 * 60 * 60)) {
|
||||
} else if (!(etm.et_flags & ETF_DAY_SET) && (diff >= (60 * 60))) {
|
||||
off_day = 1;
|
||||
} else if (!(etm.et_flags & ETF_DAY_SET)) {
|
||||
off_hour = 1;
|
||||
@ -321,7 +321,8 @@ void log_format::check_for_new_year(std::vector<logline> &dst, exttm etm,
|
||||
if (!do_change) {
|
||||
return;
|
||||
}
|
||||
log_debug("%d:detected year change", dst.size());
|
||||
log_debug("%d:detected time rollover; offsets=%d %d %d %d", dst.size(),
|
||||
off_year, off_month, off_day, off_hour);
|
||||
for (iter = dst.begin(); iter != dst.end(); iter++) {
|
||||
time_t ot = iter->get_time();
|
||||
struct tm otm;
|
||||
@ -329,7 +330,7 @@ void log_format::check_for_new_year(std::vector<logline> &dst, exttm etm,
|
||||
gmtime_r(&ot, &otm);
|
||||
otm.tm_year -= off_year;
|
||||
otm.tm_mon -= off_month;
|
||||
otm.tm_yday -= off_day;
|
||||
otm.tm_mday -= off_day;
|
||||
otm.tm_hour -= off_hour;
|
||||
iter->set_time(tm2sec(&otm));
|
||||
}
|
||||
|
@ -279,6 +279,7 @@ dist_noinst_DATA = \
|
||||
logfile_openam.0 \
|
||||
logfile_plain.0 \
|
||||
logfile_pretty.0 \
|
||||
logfile_rollover.0 \
|
||||
logfile_strace_log.0 \
|
||||
logfile_syslog.0 \
|
||||
logfile_syslog.1 \
|
||||
|
6
test/logfile_rollover.0
Normal file
6
test/logfile_rollover.0
Normal file
@ -0,0 +1,6 @@
|
||||
00:00:00.000 foo DEBUG some super duper message
|
||||
01:00:00.000 foo DEBUG some super duper message
|
||||
02:00:00.000 foo DEBUG some super duper message
|
||||
03:00:00.000 foo DEBUG some super duper message
|
||||
00:00:00.000 bar DEBUG some super duper message next day (only one hour)
|
||||
00:01:00.000 bar DEBUG some super duper message next day (only one hour)
|
@ -62,6 +62,18 @@ Dec 03 09:23:38 2006 -- 000
|
||||
Jan 03 09:47:02 2007 -- 000
|
||||
EOF
|
||||
|
||||
touch -t 200711030000 ${srcdir}/logfile_rollover.0
|
||||
run_test ./drive_logfile -t -f generic_log ${srcdir}/logfile_rollover.0
|
||||
|
||||
check_output "Generic timestamp interpreted incorrectly for day rollover?" <<EOF
|
||||
Nov 02 00:00:00 2007 -- 000
|
||||
Nov 02 01:00:00 2007 -- 000
|
||||
Nov 02 02:00:00 2007 -- 000
|
||||
Nov 02 03:00:00 2007 -- 000
|
||||
Nov 03 00:00:00 2007 -- 000
|
||||
Nov 03 00:01:00 2007 -- 000
|
||||
EOF
|
||||
|
||||
gzip -c ${srcdir}/logfile_syslog.1 > logfile_syslog.1.gz
|
||||
|
||||
run_test ./drive_logfile -t -f syslog_log logfile_syslog.1.gz
|
||||
|
Loading…
Reference in New Issue
Block a user