mirror of
https://github.com/tstack/lnav.git
synced 2024-08-17 08:50:41 +03:00
parent
69619892e2
commit
aa6708f7fb
@ -3022,6 +3022,16 @@ external_log_format::build(std::vector<lnav::console::user_message>& errors)
|
||||
|
||||
errors.emplace_back(um);
|
||||
}
|
||||
} else if (!ts_cap) {
|
||||
errors.emplace_back(
|
||||
lnav::console::user_message::error(
|
||||
attr_line_t("invalid sample log message: ")
|
||||
.append(lnav::to_json(elf_sample.s_line.pp_value)))
|
||||
.with_reason(attr_line_t("timestamp was not captured"))
|
||||
.with_snippet(elf_sample.s_line.to_snippet())
|
||||
.with_help(attr_line_t(
|
||||
"A timestamp needs to be captured in order for a "
|
||||
"line to be recognized as a log message")));
|
||||
} else {
|
||||
attr_line_t notes;
|
||||
|
||||
|
@ -17,6 +17,8 @@ TIME_FORMATS = \
|
||||
"%Y-%m-%d %H:%M:%S:%L" \
|
||||
"%Y-%m-%d %H:%M:%S" \
|
||||
"%Y-%m-%d %H:%M" \
|
||||
"%Y-%m-%dT%H:%M:%S.%N%z" \
|
||||
"%y-%m-%dT%H:%M:%S.%N%z" \
|
||||
"%Y-%m-%dT%H:%M:%S.%f%z" \
|
||||
"%y-%m-%dT%H:%M:%S.%f%z" \
|
||||
"%Y-%m-%dT%H:%M:%S.%L%z" \
|
||||
|
@ -231,6 +231,8 @@ dist_noinst_DATA = \
|
||||
ansi-colors.0.in \
|
||||
bad-config/formats/invalid-file-format/format.json \
|
||||
bad-config/formats/invalid-json-format/format.json \
|
||||
bad-config/formats/invalid-name/format.json \
|
||||
bad-config/formats/invalid-no-tscap/format.json \
|
||||
bad-config/formats/invalid-properties/format.json \
|
||||
bad-config/formats/invalid-regex/format.json \
|
||||
bad-config/formats/invalid-sample/format.json \
|
||||
|
32
test/bad-config/formats/invalid-no-tscap/format.json
Normal file
32
test/bad-config/formats/invalid-no-tscap/format.json
Normal file
@ -0,0 +1,32 @@
|
||||
{
|
||||
"$schema": "https://lnav.org/schemas/format-v1.schema.json",
|
||||
"no_tscap_log": {
|
||||
"title": "Sample with no captured timestamp",
|
||||
"multiline": true,
|
||||
"ordered-by-time": false,
|
||||
"regex": {
|
||||
"std": {
|
||||
"pattern": "^(?<container>[\\w-]+)\\s+\\|( (?<timestamp>\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{9}[+-]\\d{2}:\\d{2}))?( (?<body>.*))?$"
|
||||
}
|
||||
},
|
||||
"level-field": "timestamp",
|
||||
"module-field": "container",
|
||||
"value": {
|
||||
"container": {
|
||||
"kind": "string",
|
||||
"identifier": true
|
||||
}
|
||||
},
|
||||
"sample": [
|
||||
{
|
||||
"line": "gitea | 2023-09-24T22:15:55.346526305+02:00 2023/09/24 22:15:55 cmd/web.go:223:runWeb() [I] Starting Gitea on PID: 7"
|
||||
},
|
||||
{
|
||||
"line": "gitea | 2023/09/24 22:15:55 cmd/web.go:223:runWeb() [I] Starting Gitea on PID: 7"
|
||||
},
|
||||
{
|
||||
"line": "gitea-db-1 | 2023-09-24T22:15:37.981051393+02:00 [migrations] started"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
@ -209,6 +209,10 @@
|
||||
[1m[31m✘ error[0m: “[1mno_sample_log[0m” is not a valid log format
|
||||
[1m[31mreason[0m: log message samples must be included in a format definition
|
||||
[36m --> [0m[1m{test_dir}/bad-config/formats/no-samples/format.json[0m:4
|
||||
[1m[31m✘ error[0m: invalid sample log message: "gitea | 2023/09/24 22:15:55 cmd/web.go:223:runWeb() [I] Starting Gitea on PID: 7"
|
||||
[1m[31mreason[0m: timestamp was not captured
|
||||
[36m --> [0m[1m{test_dir}/bad-config/formats/invalid-no-tscap/format.json[0m:25
|
||||
[36m =[0m [36mhelp[0m: A timestamp needs to be captured in order for a line to be recognized as a log message
|
||||
[1m[31m✘ error[0m: failed to compile SQL statement
|
||||
[1m[31mreason[0m: near "TALE": syntax error
|
||||
[36m --> [0m[1m{test_dir}/bad-config/formats/invalid-sql/init.sql[0m:4
|
||||
|
Loading…
Reference in New Issue
Block a user