[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.
This commit is contained in:
parent
500d546706
commit
afefc9a3d4
13
src/log.c
13
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;
|
||||
|
Loading…
Reference in New Issue
Block a user