mirror of https://github.com/tstack/lnav
[config] simplify file format detection by moving it into the log format definition
parent
b1c7fad50d
commit
8df83d562a
@ -1,63 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2023, Timothy Stack
|
|
||||||
*
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of Timothy Stack nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ''AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef lnav_file_format_cfg_hh
|
|
||||||
#define lnav_file_format_cfg_hh
|
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "yajlpp/yajlpp.hh"
|
|
||||||
|
|
||||||
namespace lnav {
|
|
||||||
namespace file_formats {
|
|
||||||
|
|
||||||
struct header_exprs {
|
|
||||||
std::map<std::string, std::string> he_exprs;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct header {
|
|
||||||
header_exprs h_exprs;
|
|
||||||
size_t h_size{32};
|
|
||||||
};
|
|
||||||
|
|
||||||
struct format_def {
|
|
||||||
std::string fd_title;
|
|
||||||
header fd_header;
|
|
||||||
positioned_property<std::string> fd_converter;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct config {
|
|
||||||
std::map<std::string, format_def> c_defs;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace file_formats
|
|
||||||
} // namespace lnav
|
|
||||||
|
|
||||||
#endif
|
|
@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://lnav.org/schemas/format-v1.schema.json",
|
||||||
|
"bad_file_format1": {
|
||||||
|
"title": "bad file format",
|
||||||
|
"regex": {
|
||||||
|
"std": {
|
||||||
|
"pattern": "(?<timestamp>\\d+): (?<body>.*)$"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"converter": {
|
||||||
|
"header": {
|
||||||
|
"expr": {
|
||||||
|
"default": ":header REGEXP 'foobar"
|
||||||
|
},
|
||||||
|
"size": 8
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"timestamp-format": [
|
||||||
|
"%i"
|
||||||
|
],
|
||||||
|
"sample": [
|
||||||
|
{
|
||||||
|
"line": "1234: abcd"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
@ -1,19 +0,0 @@
|
|||||||
{
|
|
||||||
"$schema": "https://lnav.org/schemas/config-v1.schema.json",
|
|
||||||
"tuning": {
|
|
||||||
"file-format": {
|
|
||||||
"application/vnd.example.com": {
|
|
||||||
"title": "example",
|
|
||||||
"header": {
|
|
||||||
"expr": {
|
|
||||||
"default": ":header REGEXP 'foobar"
|
|
||||||
},
|
|
||||||
"size": 8
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"application/vnd.example2.com": {
|
|
||||||
"title": "example"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://lnav.org/schemas/config-v1.schema.json",
|
||||||
|
"ui": {
|
||||||
|
"theme-defs": {
|
||||||
|
"invalid-theme": {
|
||||||
|
"styles": {
|
||||||
|
"text": {
|
||||||
|
"color": "InvalidColor",
|
||||||
|
"bad-property": "abc"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue