diff --git a/src/Makefile.am b/src/Makefile.am index 6c3d5e3f..c9056e6a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -28,8 +28,9 @@ init-sql.c: bin2c TIME_FORMATS = \ "%Y-%m-%d %H:%M:%S" \ "%Y-%m-%d %H:%M" \ - "%Y-%m-%dT%H:%M:%S" \ + "%Y-%m-%dT%H:%M:%S.%f%z" \ "%Y-%m-%dT%H:%M:%SZ" \ + "%Y-%m-%dT%H:%M:%S" \ "%Y/%m/%d %H:%M:%S" \ "%Y/%m/%d %H:%M" \ "%a %b %d %H:%M:%S %Y" \ diff --git a/src/lnav_util.cc b/src/lnav_util.cc index 9e65997a..56766b3a 100644 --- a/src/lnav_util.cc +++ b/src/lnav_util.cc @@ -471,14 +471,13 @@ const char *date_time_scanner::scan(const char *time_dest, /* Try to pull out the milli/micro-second value. */ if (retval[0] == '.' || retval[0] == ',') { off_t off = (retval - time_dest) + 1; - int sub_seconds = 0; - if (ptime_f(sub_seconds, time_dest, off, time_len)) { - tv_out.tv_usec = sub_seconds; + if (ptime_f(tm_out, time_dest, off, time_len)) { + tv_out.tv_usec = tm_out->et_nsec / 1000; this->dts_fmt_len += 7; } - else if (ptime_F(sub_seconds, time_dest, off, time_len)) { - tv_out.tv_usec = sub_seconds * 1000; + else if (ptime_F(tm_out, time_dest, off, time_len)) { + tv_out.tv_usec = tm_out->et_nsec / 1000; this->dts_fmt_len += 4; } } diff --git a/src/log_format.cc b/src/log_format.cc index 9690b46f..7ca4f4f7 100644 --- a/src/log_format.cc +++ b/src/log_format.cc @@ -82,7 +82,7 @@ const char *logline::level_names[LEVEL__MAX + 1] = { }; static pcrepp LEVEL_RE( - "(?i)(TRACE|DEBUG\\d*|INFO|STATS|WARN(?:ING)?|ERROR|CRITICAL|SEVERE|FATAL)"); + "(?i)(TRACE|DEBUG\\d*|INFO|STATS|WARN(?:ING)?|ERR(OR)?|CRITICAL|SEVERE|FATAL)"); logline::level_t logline::string2level(const char *levelstr, ssize_t len, bool exact) { diff --git a/src/log_format_impls.cc b/src/log_format_impls.cc index df0ae8d0..662af870 100644 --- a/src/log_format_impls.cc +++ b/src/log_format_impls.cc @@ -87,7 +87,7 @@ class generic_log_format : public log_format { static pcre_format *get_pcre_log_formats() { static pcre_format log_fmt[] = { - { "", pcrepp("^(?[\\dTZ: ,\\.-]+)([^:]+)") }, + { "", pcrepp("^(?[\\dTZ: +/\\-,\\.-]+)([^:]+)") }, { "", pcrepp("^(?[\\w:+/\\.-]+) \\[\\w (.*)") }, { "", pcrepp("^(?[\\w:,/\\.-]+) (.*)") }, { "", pcrepp("^(?[\\w: \\.,/-]+)\\[[^\\]]+\\](.*)") }, diff --git a/src/ptimec.hh b/src/ptimec.hh index ffeb6e3d..801d14f7 100644 --- a/src/ptimec.hh +++ b/src/ptimec.hh @@ -426,9 +426,9 @@ inline bool ptime_y(struct exttm *dst, const char *str, off_t &off_inout, ssize_ return true; } +#include "lnav_log.hh" inline bool ptime_z(struct exttm *dst, const char *str, off_t &off_inout, ssize_t len) { -#ifdef HAVE_STRUCT_TM_TM_ZONE PTIME_CONSUME(5, { long sign; long hours; @@ -450,14 +450,15 @@ inline bool ptime_z(struct exttm *dst, const char *str, off_t &off_inout, ssize_ mins = ( (str[off_inout + 2] - '0') * 10 + (str[off_inout + 3] - '0') * 1) * 60; +#ifdef HAVE_STRUCT_TM_TM_ZONE dst->et_tm.tm_gmtoff = sign * (hours + mins); - }); #endif + }); return true; } -inline bool ptime_f(int &sub_seconds, const char *str, off_t &off_inout, ssize_t len) +inline bool ptime_f(struct exttm *dst, const char *str, off_t &off_inout, ssize_t len) { PTIME_CONSUME(6, { for (int lpc = 0; lpc < 6; lpc++) { @@ -465,25 +466,25 @@ inline bool ptime_f(int &sub_seconds, const char *str, off_t &off_inout, ssize_t return false; } } - sub_seconds = ( + dst->et_nsec = ( (str[off_inout + 0] - '0') * 100000 + (str[off_inout + 1] - '0') * 10000 + (str[off_inout + 2] - '0') * 1000 + (str[off_inout + 3] - '0') * 100 + (str[off_inout + 4] - '0') * 10 + - (str[off_inout + 5] - '0') * 1); + (str[off_inout + 5] - '0') * 1) * 1000; }); return true; } -inline bool ptime_F(int &sub_seconds, const char *str, off_t &off_inout, ssize_t len) +inline bool ptime_F(struct exttm *dst, const char *str, off_t &off_inout, ssize_t len) { PTIME_CONSUME(3, { - sub_seconds = ( + dst->et_nsec = ( (str[off_inout + 0] - '0') * 100 + (str[off_inout + 1] - '0') * 10 + - (str[off_inout + 2] - '0') * 1); + (str[off_inout + 2] - '0') * 1) * 1000 * 1000; }); return true; diff --git a/test/Makefile.am b/test/Makefile.am index bc5f6290..b3b513b1 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -221,6 +221,7 @@ dist_noinst_DATA = \ logfile_for_join.0 \ logfile_generic.0 \ logfile_generic.1 \ + logfile_generic.2 \ logfile_glog.0 \ logfile_json.json \ logfile_multiline.0 \ diff --git a/test/logfile_generic.2 b/test/logfile_generic.2 new file mode 100644 index 00000000..71cc21a2 --- /dev/null +++ b/test/logfile_generic.2 @@ -0,0 +1,2 @@ +2015-04-24T21:08:10.313913+00:00 err rbd [22968]lotuscreds:ERROR:Could not retrieve lotus account information from db +2015-04-24T21:08:58.430632+00:00 err rbd [24206]networkutil:ERROR:The configured address sg01-1-vc1.oc.vmware.com was invalid diff --git a/test/test_logfile.sh b/test/test_logfile.sh index df361aee..0370a2ea 100644 --- a/test/test_logfile.sh +++ b/test/test_logfile.sh @@ -179,11 +179,18 @@ EOF run_test ./drive_logfile -v -f generic_log ${srcdir}/logfile_generic.1 -check_output "generic_log level interpreted incorrectly?" <