mirror of
https://github.com/tstack/lnav
synced 2024-11-03 23:15:38 +00:00
[loader] add some help text to the error for values without a corresponding capture
This commit is contained in:
parent
001f26d066
commit
74c2237296
@ -1904,6 +1904,8 @@ external_log_format::build(std::vector<lnav::console::user_message>& errors)
|
||||
}
|
||||
|
||||
if (this->elf_type == elf_type_t::ELF_TYPE_TEXT) {
|
||||
std::set<std::string> available_captures;
|
||||
|
||||
bool found_in_pattern = false;
|
||||
for (const auto& pat : this->elf_patterns) {
|
||||
auto cap_index = pat.second->p_pcre->name_index(
|
||||
@ -1912,8 +1914,20 @@ external_log_format::build(std::vector<lnav::console::user_message>& errors)
|
||||
found_in_pattern = true;
|
||||
break;
|
||||
}
|
||||
|
||||
for (auto name_iter = pat.second->p_pcre->named_begin();
|
||||
name_iter != pat.second->p_pcre->named_end();
|
||||
++name_iter)
|
||||
{
|
||||
available_captures.insert(name_iter->pnc_name);
|
||||
}
|
||||
}
|
||||
if (!found_in_pattern) {
|
||||
auto notes
|
||||
= attr_line_t("the following captures are available:\n ")
|
||||
.join(available_captures,
|
||||
VC_ROLE.value(role_t::VCR_SYMBOL),
|
||||
", ");
|
||||
errors.emplace_back(
|
||||
lnav::console::user_message::error(
|
||||
attr_line_t("invalid value ")
|
||||
@ -1924,7 +1938,11 @@ external_log_format::build(std::vector<lnav::console::user_message>& errors)
|
||||
.with_reason(
|
||||
attr_line_t("no patterns have a capture named ")
|
||||
.append_quoted(vd->vd_meta.lvm_name.get()))
|
||||
.with_snippets(this->get_snippets()));
|
||||
.with_note(notes)
|
||||
.with_snippets(this->get_snippets())
|
||||
.with_help("values are populated from captures in "
|
||||
"patterns, so at least one pattern must "
|
||||
"have a capture with this value name"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,6 +101,9 @@
|
||||
[1m[31m✘ error[0m: invalid value “[1m/invalid_props_log/value/non-existent[0m”
|
||||
[1m[31mreason[0m: no patterns have a capture named “non-existent”
|
||||
[36m --> [0m[1m{test_dir}/bad-config/formats/invalid-properties/format.json[0m:4
|
||||
[36m =[0m [36mnote[0m: the following captures are available:
|
||||
[1mbody[0m, [1mpid[0m, [1mtimestamp[0m
|
||||
[36m =[0m [36mhelp[0m: values are populated from captures in patterns, so at least one pattern must have a capture with this value name
|
||||
[1m[31m✘ error[0m: invalid value for property “[1m/invalid_props_log/timestamp-field[0m”
|
||||
[1m[31mreason[0m: “ts” was not found in the pattern at [1m/invalid_props_log/regex/std[0m
|
||||
[36m --> [0m[1m{test_dir}/bad-config/formats/invalid-properties/format.json[0m:4
|
||||
|
Loading…
Reference in New Issue
Block a user