1
1
mirror of https://github.com/tstack/lnav.git synced 2024-09-11 13:05:51 +03:00

[log_format] fix issues with year rollover

Defect Number:
    Reviewed By:
   Testing Done:
This commit is contained in:
Timothy Stack 2020-09-08 22:02:33 -07:00
parent 8a3fbe6375
commit a3264fb104
5 changed files with 12 additions and 6 deletions

View File

@ -248,7 +248,11 @@ void log_format::check_for_new_year(std::vector<logline> &dst, exttm etm,
otm.tm_mon -= off_month;
otm.tm_mday -= off_day;
otm.tm_hour -= off_hour;
iter->set_time(tm2sec(&otm));
auto new_time = tm2sec(&otm);
if (new_time == -1) {
continue;
}
iter->set_time(new_time);
}
}

View File

@ -806,7 +806,7 @@ public:
std::vector<pattern_for_lines> lf_pattern_locks;
intern_string_t lf_timestamp_field;
std::vector<const char *> lf_timestamp_format;
int lf_timestamp_flags;
unsigned int lf_timestamp_flags;
std::map<std::string, action_def> lf_action_defs;
std::vector<logline_value_stats> lf_value_stats;
std::vector<highlighter> lf_highlighters;

View File

@ -144,7 +144,7 @@ bool logfile::process_prefix(shared_buffer_ref &sbr, const line_info &li)
if (this->lf_format.get() != nullptr) {
if (!this->lf_index.empty()) {
prescan_time = this->lf_index[0].get_time();
prescan_time = this->lf_index[prescan_size - 1].get_time();
}
/* We've locked onto a format, just use that scanner. */
found = this->lf_format->scan(*this, this->lf_index, li, sbr);
@ -205,7 +205,9 @@ bool logfile::process_prefix(shared_buffer_ref &sbr, const line_info &li)
if (!this->lf_index.empty()) {
this->lf_index.back().set_valid_utf(li.li_valid_utf);
}
if (!this->lf_index.empty() && prescan_time != this->lf_index[0].get_time()) {
if (prescan_size > 0 &&
this->lf_index.size() >= prescan_size &&
prescan_time != this->lf_index[prescan_size - 1].get_time()) {
retval = true;
}
if (prescan_size > 0 && prescan_size < this->lf_index.size()) {

View File

@ -592,7 +592,7 @@ logfile_sub_source::rebuild_result logfile_sub_source::rebuild_index()
retval = rebuild_result::rr_appended_lines;
}
if (!this->lss_index.empty()) {
logline &new_file_line = lf[ld.ld_lines_indexed];
logline &new_file_line = lf[ld.ld_lines_indexed - 1];
content_line_t cl = this->lss_index.back();
logline *last_indexed_line = this->find_line(cl);

View File

@ -69,7 +69,7 @@ enum exttm_flags_t {
struct exttm {
struct tm et_tm;
int32_t et_nsec;
int et_flags;
unsigned int et_flags;
long et_gmtoff;
bool operator==(const exttm &other) const {