mirror of
https://github.com/tstack/lnav
synced 2024-11-01 21:40:34 +00:00
parent
a2f076a967
commit
44b564681b
@ -95,9 +95,10 @@ like so:
|
||||
}
|
||||
|
||||
Each format to be defined in the file should be a separate field in the top-level
|
||||
object. The field name should be the symbolic name of the format. This value
|
||||
will also be used as the SQL table name for the log. The value for each field
|
||||
should be another object with the following fields:
|
||||
object. The field name should be the symbolic name of the format and consist
|
||||
only of alphanumeric characters and underscores. This value will also be used
|
||||
as the SQL table name for the log. The value for each field should be another
|
||||
object with the following fields:
|
||||
|
||||
:title: The short and human-readable name for the format.
|
||||
:description: A longer description of the format.
|
||||
|
@ -529,12 +529,11 @@ static const json_path_handler_base::enum_value_t SCALE_OP_ENUM[] = {
|
||||
};
|
||||
|
||||
static const struct json_path_container scaling_factor_handlers = {
|
||||
yajlpp::pattern_property_handler("op")
|
||||
yajlpp::property_handler("op")
|
||||
.with_enum_values(SCALE_OP_ENUM)
|
||||
.for_field(&scaling_factor::sf_op),
|
||||
|
||||
yajlpp::pattern_property_handler("value").for_field(
|
||||
&scaling_factor::sf_value),
|
||||
yajlpp::property_handler("value").for_field(&scaling_factor::sf_value),
|
||||
};
|
||||
|
||||
static const struct json_path_container scale_handlers = {
|
||||
|
@ -240,7 +240,21 @@ TEST_CASE("get_captures-namedq")
|
||||
{
|
||||
auto re = lnav::pcre2pp::code::from_const("(?'named'b)");
|
||||
|
||||
assert(re.get_captures().size() == 1);
|
||||
assert(re.get_captures()[0].sf_begin == 0);
|
||||
assert(re.get_captures()[0].sf_end == 11);
|
||||
CHECK(re.get_captures().size() == 1);
|
||||
CHECK(re.get_captures()[0].sf_begin == 0);
|
||||
CHECK(re.get_captures()[0].sf_end == 11);
|
||||
}
|
||||
|
||||
TEST_CASE("anchored")
|
||||
{
|
||||
auto re = lnav::pcre2pp::code::from_const(
|
||||
"abc", PCRE2_ANCHORED | PCRE2_ENDANCHORED);
|
||||
|
||||
const auto sub1 = string_fragment::from_const("abc");
|
||||
const auto sub2 = string_fragment::from_const("abcd");
|
||||
const auto sub3 = string_fragment::from_const("0abc");
|
||||
|
||||
CHECK(re.find_in(sub1).ignore_error().has_value());
|
||||
CHECK_FALSE(re.find_in(sub2).ignore_error().has_value());
|
||||
CHECK_FALSE(re.find_in(sub3).ignore_error().has_value());
|
||||
}
|
||||
|
@ -716,7 +716,8 @@ yajlpp_parse_context::update_callbacks(const json_path_container* orig_handlers,
|
||||
if (jph.jph_regex->capture_from(path_frag)
|
||||
.into(md)
|
||||
.matches()
|
||||
.ignore_error())
|
||||
.ignore_error()
|
||||
&& (md.remaining().empty() || md.remaining().startswith("/")))
|
||||
{
|
||||
auto cap = md[0].value();
|
||||
|
||||
|
@ -1380,7 +1380,7 @@ template<typename T, std::size_t N>
|
||||
inline json_path_handler
|
||||
pattern_property_handler(const T (&path)[N])
|
||||
{
|
||||
return {lnav::pcre2pp::code::from_const(path).to_shared()};
|
||||
return {lnav::pcre2pp::code::from_const(path, PCRE2_ANCHORED).to_shared()};
|
||||
}
|
||||
|
||||
} // namespace yajlpp
|
||||
|
8
test/bad-config/formats/invalid-name/format.json
Normal file
8
test/bad-config/formats/invalid-name/format.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"$schema": "https://lnav.org/schemas/format-v1.schema.json",
|
||||
"bad-name-log": {
|
||||
"title": "bad-format",
|
||||
"description": "Log format with a name that has invalid characters",
|
||||
"json": true
|
||||
}
|
||||
}
|
@ -6,6 +6,24 @@
|
||||
[1m/bad_json_log/line-format#/timestamp-format[0m [4m<string>[0m
|
||||
[1mDescription[0m
|
||||
The strftime(3) format for this field
|
||||
[33m⚠ warning[0m: unexpected value for property “[1m/bad-name-log/title[0m”
|
||||
[36m --> [0m[1m{test_dir}/bad-config/formats/invalid-name/format.json[0m:4
|
||||
[36m | [0m[37m[40m "title": "bad-format", [0m
|
||||
[36m =[0m [36mhelp[0m: [1mAvailable Properties[0m
|
||||
[1m$schema[0m [4mThe URI of the schema for this file[0m
|
||||
[1m(\w+)[0m[1m/[0m
|
||||
[33m⚠ warning[0m: unexpected value for property “[1m/bad-name-log/description[0m”
|
||||
[36m --> [0m[1m{test_dir}/bad-config/formats/invalid-name/format.json[0m:5
|
||||
[36m | [0m[37m[40m "description": "Log format with a name that has invalid characters",[0m
|
||||
[36m =[0m [36mhelp[0m: [1mAvailable Properties[0m
|
||||
[1m$schema[0m [4mThe URI of the schema for this file[0m
|
||||
[1m(\w+)[0m[1m/[0m
|
||||
[33m⚠ warning[0m: unexpected value for property “[1m/bad-name-log/json[0m”
|
||||
[36m --> [0m[1m{test_dir}/bad-config/formats/invalid-name/format.json[0m:6
|
||||
[36m | [0m[37m[40m "json": true [0m
|
||||
[36m =[0m [36mhelp[0m: [1mAvailable Properties[0m
|
||||
[1m$schema[0m [4mThe URI of the schema for this file[0m
|
||||
[1m(\w+)[0m[1m/[0m
|
||||
[1m[31m✘ error[0m: “invalid(abc” is not a valid regular expression
|
||||
[1m[31mreason[0m: missing closing parenthesis
|
||||
[36m --> [0m[1m/invalid_props_log/tags/badtag3/pattern[0m
|
||||
|
Loading…
Reference in New Issue
Block a user