mirror of
https://github.com/tstack/lnav.git
synced 2024-08-17 00:40:30 +03:00
[loader] the loader was not converting the level name to the enum value correctly
Closes #329
This commit is contained in:
parent
2f0d645a26
commit
8dbf018814
@ -99,7 +99,7 @@ logline::level_t logline::string2level(const char *levelstr, ssize_t len, bool e
|
||||
}
|
||||
|
||||
if (((len == 1) || ((len > 1) && (levelstr[1] == ' '))) &&
|
||||
(retval = abbrev2level(levelstr, len)) != LEVEL_UNKNOWN) {
|
||||
(retval = abbrev2level(levelstr, 1)) != LEVEL_UNKNOWN) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ logline::level_t logline::string2level(const char *levelstr, ssize_t len, bool e
|
||||
pcre_context_static<10> pc;
|
||||
|
||||
if (LEVEL_RE.match(pc, pi)) {
|
||||
retval = abbrev2level(pi.get_substr_start(pc.begin()), 1);
|
||||
retval = abbrev2level(pi.get_substr_start(pc.begin()), len);
|
||||
}
|
||||
|
||||
return retval;
|
||||
|
@ -192,7 +192,6 @@ static int read_levels(yajlpp_parse_context *ypc, const unsigned char *str, size
|
||||
string regex = string((const char *)str, len);
|
||||
string level_name_or_number = ypc->get_path_fragment(2);
|
||||
logline::level_t level = logline::string2level(level_name_or_number.c_str());
|
||||
|
||||
elf->elf_level_patterns[level].lp_regex = regex;
|
||||
|
||||
return 1;
|
||||
|
@ -274,6 +274,7 @@ dist_noinst_DATA = \
|
||||
logfile_glog.0 \
|
||||
logfile_json.json \
|
||||
logfile_json2.json \
|
||||
logfile_leveltest.0 \
|
||||
logfile_multiline.0 \
|
||||
logfile_nested_json.json \
|
||||
logfile_openam.0 \
|
||||
@ -306,6 +307,7 @@ dist_noinst_DATA = \
|
||||
vt52_curses_output.0 \
|
||||
vt52_curses_output.1 \
|
||||
formats/collision/format.json \
|
||||
formats/customlevel/format.json \
|
||||
formats/jsontest/format.json \
|
||||
formats/jsontest2/format.json \
|
||||
formats/nestedjson/format.json \
|
||||
|
24
test/formats/customlevel/format.json
Normal file
24
test/formats/customlevel/format.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"leveltest_log": {
|
||||
"description": "Log format used for testing levels",
|
||||
"regex": {
|
||||
"line": {
|
||||
"pattern": "^(?<timestamp>\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}) (?<level>[^ ]+) (?<body>.*)$"
|
||||
}
|
||||
},
|
||||
"level": {
|
||||
"trace": "trace",
|
||||
"debug": "debug",
|
||||
"debug2": "debug2",
|
||||
"debug3": "debug3",
|
||||
"info": "info",
|
||||
"warning": "warn",
|
||||
"fatal": "fatal"
|
||||
},
|
||||
"sample": [
|
||||
{
|
||||
"line": "2016-06-30 12:00:01 trace tracemessage"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
8
test/logfile_leveltest.0
Normal file
8
test/logfile_leveltest.0
Normal file
@ -0,0 +1,8 @@
|
||||
2016-06-30 12:00:01 trace tracemessage
|
||||
2016-06-30 12:00:02 debug debugmessage
|
||||
2016-06-30 12:00:03 debug2 debug2message
|
||||
2016-06-30 12:00:04 debug3 debug3message
|
||||
2016-06-30 12:00:05 info infomessage
|
||||
2016-06-30 12:00:06 warn warnmessage
|
||||
2016-06-30 12:00:07 fatal fatalmessage
|
||||
2016-06-30 12:00:08 invalid invalidmessage
|
@ -20,3 +20,21 @@ error: against pattern -- ^(?<timestamp>\d+): (?<body>.*)$
|
||||
error:no_sample_log:no sample logs provided, all formats must have samples
|
||||
error:init.sql:2:near "TALE": syntax error
|
||||
EOF
|
||||
|
||||
run_test ${lnav_test} -n \
|
||||
-I ${test_dir} \
|
||||
-c ";select * from leveltest_log" \
|
||||
-c ':write-csv-to -' \
|
||||
${test_dir}/logfile_leveltest.0
|
||||
|
||||
check_output "levels are not correct?" <<EOF
|
||||
log_line,log_part,log_time,log_idle_msecs,log_level,log_mark
|
||||
0,<NULL>,2016-06-30 12:00:01.000,0,trace,0
|
||||
1,<NULL>,2016-06-30 12:00:02.000,1000,debug,0
|
||||
2,<NULL>,2016-06-30 12:00:03.000,1000,debug2,0
|
||||
3,<NULL>,2016-06-30 12:00:04.000,1000,debug3,0
|
||||
4,<NULL>,2016-06-30 12:00:05.000,1000,info,0
|
||||
5,<NULL>,2016-06-30 12:00:06.000,1000,warning,0
|
||||
6,<NULL>,2016-06-30 12:00:07.000,1000,fatal,0
|
||||
7,<NULL>,2016-06-30 12:00:08.000,1000,info,0
|
||||
EOF
|
||||
|
Loading…
Reference in New Issue
Block a user