mirror of https://github.com/tstack/lnav.git
[format] hidden object/array fields add sub-lines when they should not
Fixes #576
This commit is contained in:
parent
b4e7bc9b0f
commit
e001b49e28
|
@ -367,20 +367,11 @@ static int json_array_start(void *ctx)
|
|||
{
|
||||
yajlpp_parse_context *ypc = (yajlpp_parse_context *)ctx;
|
||||
json_log_userdata *jlu = (json_log_userdata *)ypc->ypc_userdata;
|
||||
vector<external_log_format::json_format_element> &line_format =
|
||||
jlu->jlu_format->jlf_line_format;
|
||||
|
||||
if (ypc->ypc_path_index_stack.size() == 2) {
|
||||
const intern_string_t field_name = ypc->get_path_fragment_i(0);
|
||||
|
||||
if (!jlu->jlu_format->jlf_hide_extra &&
|
||||
find_if(line_format.begin(), line_format.end(),
|
||||
external_log_format::json_field_cmp(
|
||||
external_log_format::JLF_VARIABLE,
|
||||
field_name)) == line_format.end()) {
|
||||
jlu->jlu_sub_line_count += 1;
|
||||
}
|
||||
|
||||
jlu->jlu_sub_line_count += jlu->jlu_format->value_line_count(field_name, true);
|
||||
jlu->jlu_sub_start = yajl_get_bytes_consumed(jlu->jlu_handle) - 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,15 @@
|
|||
},
|
||||
"response/status": {
|
||||
"kind": "string"
|
||||
},
|
||||
"details1" : {
|
||||
"hidden": true
|
||||
},
|
||||
"details2" : {
|
||||
"hidden": true
|
||||
},
|
||||
"details3" : {
|
||||
"hidden": true
|
||||
}
|
||||
},
|
||||
"timestamp-field" : "started_at",
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
{ "started_at": 1490385986240, "response": { "status": 200, "size": "443", "headers": { "server": "nginx\/1.11.10", "content-type": "application\/json", "connection": "close", "cache-control": "max-age=0, must-revalidate, no-cache, no-store, private" } }, "request": { "method": "GET", "uri": "\/example\/uri\/5", "size": "166", "querystring": {}, "headers": { "host": "example.com" } }, "client_ip": "1.1.1.1" }
|
||||
{ "started_at": 1490386367764, "response": { "status": 500, "size": "443", "headers": { "server": "nginx\/1.11.10", "content-type": "application\/json", "connection": "close", "cache-control": "max-age=0, must-revalidate, no-cache, no-store, private" } }, "request": { "method": "GET", "uri": "\/example\/uri\/5", "size": "166", "querystring": {}, "headers": { "host": "example.com" } }, "client_ip": "1.1.1.1" }
|
||||
{ "started_at": 1490386531694, "response": { "status": 400, "size": "443", "headers": { "server": "nginx\/1.11.10", "content-type": "application\/json", "connection": "close", "cache-control": "max-age=0, must-revalidate, no-cache, no-store, private" } }, "request": { "method": "GET", "uri": "\/example\/uri\/5", "size": "166", "querystring": {}, "headers": { "host": "example.com" } }, "client_ip": "1.1.1.1" }
|
||||
{ "started_at": 1490386531694, "response": { "status": 400, "size": "443", "headers": { "server": "nginx\/1.11.10", "content-type": "application\/json", "connection": "close", "cache-control": "max-age=0, must-revalidate, no-cache, no-store, private" } }, "request": { "method": "GET", "uri": "\/example\/uri\/5", "size": "166", "querystring": {}, "headers": { "host": "example.com" } }, "client_ip": "1.1.1.1", "details1": {"foo": "bar"}, "details2": {"foo": "bar"}, "details3": {"foo": "bar"} }
|
||||
|
|
|
@ -464,8 +464,8 @@ run_test ${lnav_test} -n \
|
|||
${test_dir}/logfile_json3.json
|
||||
|
||||
check_output "json log3 format is not working" <<EOF
|
||||
log_line,log_part,log_time,log_idle_msecs,log_level,log_mark,log_comment,log_tags,client_ip,request/method,request/size,request/uri,response/status
|
||||
0,<NULL>,2017-03-24 20:06:26.240,0,info,0,<NULL>,<NULL>,1.1.1.1,GET,166,/example/uri/5,200
|
||||
1,<NULL>,2017-03-24 20:12:47.764,381524,critical,0,<NULL>,<NULL>,1.1.1.1,GET,166,/example/uri/5,500
|
||||
2,<NULL>,2017-03-24 20:15:31.694,163930,warning,0,<NULL>,<NULL>,1.1.1.1,GET,166,/example/uri/5,400
|
||||
log_line,log_part,log_time,log_idle_msecs,log_level,log_mark,log_comment,log_tags,client_ip,details1,details2,details3,request/method,request/size,request/uri,response/status
|
||||
0,<NULL>,2017-03-24 20:06:26.240,0,info,0,<NULL>,<NULL>,1.1.1.1,<NULL>,<NULL>,<NULL>,GET,166,/example/uri/5,200
|
||||
1,<NULL>,2017-03-24 20:12:47.764,381524,critical,0,<NULL>,<NULL>,1.1.1.1,<NULL>,<NULL>,<NULL>,GET,166,/example/uri/5,500
|
||||
2,<NULL>,2017-03-24 20:15:31.694,163930,warning,0,<NULL>,<NULL>,1.1.1.1,"{""foo"": ""bar""}","{""foo"": ""bar""}","{""foo"": ""bar""}",GET,166,/example/uri/5,400
|
||||
EOF
|
||||
|
|
Loading…
Reference in New Issue