mirror of
https://github.com/tstack/lnav
synced 2024-11-17 15:29:40 +00:00
[docs] json format docs and some build fixes
This commit is contained in:
parent
c59acba758
commit
a8c3a8c80b
@ -39,15 +39,45 @@ fields:
|
||||
:description: A longer description of the format.
|
||||
:url: A URL to the definition of the format.
|
||||
|
||||
:file-pattern: A regular expression used to match log file paths. Typically,
|
||||
every file format will be tried during the detection process. This field
|
||||
can be used to limit which files a format is applied to in case there is
|
||||
a potential for conflicts.
|
||||
|
||||
:regex: This object contains sub-objects that describe the message formats
|
||||
to match in a log file.
|
||||
to match in a plain log file. Log files that contain JSON messages should
|
||||
not specify this field.
|
||||
|
||||
:pattern: The regular expression that should be used to match log messages.
|
||||
The `PCRE <http://www.pcre.org>`_ library is used by **lnav** to do all
|
||||
regular expression matching.
|
||||
|
||||
:json: True if each log line is JSON-encoded.
|
||||
|
||||
:line-format: An array that specifies the text format for JSON-encoded
|
||||
log messages. Log files that are JSON-encoded will have each message
|
||||
converted from the raw JSON encoding into this format. Each element
|
||||
is either an object that defines which fields should be inserted into
|
||||
the final message string and or a string constant that should be
|
||||
inserted. For example, the following configuration will tranform each
|
||||
log message object into a string that contains the timestamp, followed
|
||||
by a space, and then the message body::
|
||||
|
||||
[ { "field": "ts" }, " ", { "field": "msg" } ]
|
||||
|
||||
:field: The name of the message field that should be inserted at this
|
||||
point in the message.
|
||||
:default-value: The default value to use if the field could not be found
|
||||
in the current log message. The built-in default is "-".
|
||||
|
||||
:timestamp-field: The name of the field that contains the log message
|
||||
timestamp. Defaults to "timestamp".
|
||||
|
||||
:level-field: The name of the regex capture group that contains the log
|
||||
message level.
|
||||
message level. Defaults to "level".
|
||||
|
||||
:body-field: The name of the field that contains the main body of the
|
||||
message. Defaults to "body".
|
||||
|
||||
:level: A mapping of error levels to regular expressions. During scanning
|
||||
the contents of the capture group specified by *level-field* will be
|
||||
|
@ -373,7 +373,7 @@
|
||||
"tcsh_history" : {
|
||||
"title" : "TCSH History",
|
||||
"description" : "The tcsh history file format.",
|
||||
"local-time" : true,
|
||||
"convert-to-local-time" : true,
|
||||
"regex" : {
|
||||
"std" : {
|
||||
"pattern" : "^#(?<timestamp>\\+\\d+)\\n?(?<body>.*)?$"
|
||||
|
@ -381,7 +381,7 @@ static int rewrite_json_int(yajlpp_parse_context *ypc, long long val)
|
||||
json_log_userdata *jlu = (json_log_userdata *)ypc->ypc_userdata;
|
||||
string field_name = ypc->get_path_fragment(0);
|
||||
|
||||
jlu->jlu_format->jlf_line_values.push_back(logline_value(field_name, val));
|
||||
jlu->jlu_format->jlf_line_values.push_back(logline_value(field_name, (int64_t)val));
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -535,7 +535,7 @@ void external_log_format::annotate(const std::string &line,
|
||||
lr.lr_end = cap->c_end;
|
||||
sa[lr].insert(make_string_attr("timestamp", 0));
|
||||
|
||||
cap = pc["body"];
|
||||
cap = pc[this->elf_body_field];
|
||||
if (cap != NULL && cap->c_begin != -1) {
|
||||
lr.lr_start = cap->c_begin;
|
||||
lr.lr_end = cap->c_end;
|
||||
@ -713,7 +713,6 @@ void external_log_format::get_subline(const logline &ll,
|
||||
else if (lv_iter->lv_name == this->elf_body_field)
|
||||
this->jlf_line_attrs[lr].insert(make_string_attr("body", 0));
|
||||
else if (lv_iter->lv_identifier) {
|
||||
fprintf(stderr, "ident!! %s\n", lv_iter->lv_name.c_str());
|
||||
this->jlf_line_attrs[lr].insert(make_string_attr("style", vc.attrs_for_ident(str.c_str(), lr.length())));
|
||||
}
|
||||
used_values[distance(this->jlf_line_values.begin(),
|
||||
|
@ -76,7 +76,7 @@ static int read_format_bool(yajlpp_parse_context *ypc, int val)
|
||||
external_log_format *elf = ensure_format(ypc->get_path_fragment(0));
|
||||
string field_name = ypc->get_path_fragment(1);
|
||||
|
||||
if (field_name == "local-time")
|
||||
if (field_name == "convert-to-local-time")
|
||||
elf->lf_date_time.dts_local_time = val;
|
||||
else if (field_name == "json")
|
||||
elf->jlf_json = val;
|
||||
@ -266,7 +266,7 @@ static int read_json_variable_num(yajlpp_parse_context *ypc, long long val)
|
||||
|
||||
static struct json_path_handler format_handlers[] = {
|
||||
json_path_handler("^/\\w+/regex/[^/]+/pattern$", read_format_regex),
|
||||
json_path_handler("^/\\w+/(json|local-time)$", read_format_bool),
|
||||
json_path_handler("^/\\w+/(json|convert-to-local-time)$", read_format_bool),
|
||||
json_path_handler("^/\\w+/(file-pattern|level-field|timestamp-field|body-field|url|title|description)$",
|
||||
read_format_field),
|
||||
json_path_handler("^/\\w+/level/"
|
||||
|
Loading…
Reference in New Issue
Block a user