From afefc9a3d4590f488e3ffba3c9d016c0c335ef13 Mon Sep 17 00:00:00 2001 From: Arnaud Cornet Date: Tue, 20 Jan 2009 19:30:20 +0100 Subject: [PATCH] [FIX] Try to guess current daylight saving time When backloging we have no clue of a log lines dst, we try to guess it with current dst, which makes no sense, but at least it provides decent result when not near dst change. --- src/log.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/log.c b/src/log.c index 3f1632c..fcc1856 100644 --- a/src/log.c +++ b/src/log.c @@ -914,6 +914,13 @@ static time_t compute_time(const char *buf) { struct tm tm; int err; + time_t tv; + + /* this is to fill tm_isdst to current tm, expect brokennes when dst + * changes */ + time(&tv); + tm = *localtime(&tv); + err = sscanf(buf, "%2d-%2d-%4d %2d:%2d:%2d", &tm.tm_mday, &tm.tm_mon, &tm.tm_year, &tm.tm_hour, &tm.tm_min, &tm.tm_sec); if (err != 6) @@ -981,8 +988,12 @@ static int log_backread_file(log_t *log, logstore_t *store, logfile_t *lf, if (start != 0) { time_t linetime = compute_time(buf); /* parse error, don't backlog */ - if (linetime == (time_t)-1) + if (linetime == (time_t)-1) { + list_add_last(res, _log_wrap("Error in " + "timestamp in %s", + store->name)); continue; + } /* too old line, don't backlog */ if (linetime < start) continue;