mirror of
https://github.com/tstack/lnav.git
synced 2024-10-26 13:16:11 +03:00
[config] fix static init ordering issue
This commit is contained in:
parent
3ae3515f44
commit
7dfecc556f
@ -202,6 +202,12 @@ struct string_fragment {
|
||||
return memcmp(this->data(), sf.data(), sf.length()) == 0;
|
||||
}
|
||||
|
||||
int operator<(const string_fragment& rhs) const
|
||||
{
|
||||
return strncmp(
|
||||
this->data(), rhs.data(), std::min(this->length(), rhs.length()));
|
||||
}
|
||||
|
||||
bool iequal(const string_fragment& sf) const
|
||||
{
|
||||
if (this->length() != sf.length()) {
|
||||
|
@ -1430,6 +1430,8 @@ const json_path_container lnav_config_handlers = json_path_container {
|
||||
|
||||
class active_key_map_listener : public lnav_config_listener {
|
||||
public:
|
||||
active_key_map_listener() : lnav_config_listener(__FILE__) {}
|
||||
|
||||
void reload_config(error_reporter& reporter) override
|
||||
{
|
||||
lnav_config.lc_active_keymap = lnav_config.lc_ui_keymaps["default"];
|
||||
|
@ -42,10 +42,17 @@ public:
|
||||
using error_reporter = const std::function<void(
|
||||
const void*, const lnav::console::user_message& msg)>;
|
||||
|
||||
lnav_config_listener()
|
||||
template<typename T, std::size_t N>
|
||||
lnav_config_listener(const T (&src_file)[N])
|
||||
: lcl_name(string_fragment::from_const(src_file))
|
||||
{
|
||||
this->lcl_next = LISTENER_LIST;
|
||||
LISTENER_LIST = this;
|
||||
auto** curr = &LISTENER_LIST;
|
||||
|
||||
while (*curr != nullptr && (*curr)->lcl_name < this->lcl_name) {
|
||||
curr = &(*curr)->lcl_next;
|
||||
}
|
||||
this->lcl_next = *curr;
|
||||
*curr = this;
|
||||
}
|
||||
|
||||
virtual ~lnav_config_listener() = default;
|
||||
@ -54,7 +61,8 @@ public:
|
||||
|
||||
virtual void unload_config() {}
|
||||
|
||||
static void unload_all() {
|
||||
static void unload_all()
|
||||
{
|
||||
auto* lcl = LISTENER_LIST;
|
||||
while (lcl != nullptr) {
|
||||
lcl->unload_config();
|
||||
@ -65,6 +73,7 @@ public:
|
||||
static lnav_config_listener* LISTENER_LIST;
|
||||
|
||||
lnav_config_listener* lcl_next;
|
||||
string_fragment lcl_name;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -52,6 +52,8 @@ struct compiled_cond_expr {
|
||||
};
|
||||
|
||||
struct expressions : public lnav_config_listener {
|
||||
expressions() : lnav_config_listener(__FILE__) {}
|
||||
|
||||
void reload_config(error_reporter& reporter) override
|
||||
{
|
||||
auto& lnav_db = injector::get<auto_sqlite3&>();
|
||||
|
@ -50,6 +50,8 @@ struct compiled_watch_expr {
|
||||
};
|
||||
|
||||
struct expressions : public lnav_config_listener {
|
||||
expressions() : lnav_config_listener(__FILE__) {}
|
||||
|
||||
void reload_config(error_reporter& reporter) override
|
||||
{
|
||||
auto& lnav_db = injector::get<auto_sqlite3&>();
|
||||
@ -98,9 +100,7 @@ struct expressions : public lnav_config_listener {
|
||||
}
|
||||
}
|
||||
|
||||
void unload_config() override {
|
||||
this->e_watch_exprs.clear();
|
||||
}
|
||||
void unload_config() override { this->e_watch_exprs.clear(); }
|
||||
|
||||
std::map<std::string, compiled_watch_expr> e_watch_exprs;
|
||||
};
|
||||
|
@ -1845,6 +1845,8 @@ struct compiled_header_expr {
|
||||
};
|
||||
|
||||
struct format_header_expressions : public lnav_config_listener {
|
||||
format_header_expressions() : lnav_config_listener(__FILE__) {}
|
||||
|
||||
auto_sqlite3 e_db;
|
||||
std::map<intern_string_t, std::map<std::string, compiled_header_expr>>
|
||||
e_header_exprs;
|
||||
|
@ -182,7 +182,8 @@ const bookmark_type_t textview_curses::BM_USER_EXPR("user-expr");
|
||||
const bookmark_type_t textview_curses::BM_SEARCH("search");
|
||||
const bookmark_type_t textview_curses::BM_META("meta");
|
||||
|
||||
textview_curses::textview_curses() : tc_search_action(noop_func{})
|
||||
textview_curses::textview_curses()
|
||||
: lnav_config_listener(__FILE__), tc_search_action(noop_func{})
|
||||
{
|
||||
this->set_data_source(this);
|
||||
}
|
||||
|
@ -498,6 +498,8 @@ static std::string COLOR_NAMES[] = {
|
||||
|
||||
class color_listener : public lnav_config_listener {
|
||||
public:
|
||||
color_listener() : lnav_config_listener(__FILE__) {}
|
||||
|
||||
void reload_config(error_reporter& reporter) override
|
||||
{
|
||||
if (!view_colors::initialized) {
|
||||
|
@ -55,6 +55,18 @@
|
||||
[1m[31m✘ error[0m: invalid JSON
|
||||
[1m[31mreason[0m: parse error: premature EOF
|
||||
[36m --> [0m[1m{test_dir}/bad-config2/formats/invalid-config/config.truncated.json[0m:3
|
||||
[1m[31m✘ error[0m: invalid value for property “[1m/ui/theme-defs/invalid-theme/styles/text/color[0m”
|
||||
[1m[31mreason[0m: invalid color -- “InvalidColor”
|
||||
[1m[31m | [0m [1m[31mreason[0m: Unknown color: 'InvalidColor'. See https://jonasjacek.github.io/colors/ for a list of supported color names
|
||||
[36m --> [0m[1m{test_dir}/bad-config2/configs/invalid-theme/config.json[0m:8
|
||||
[36m =[0m [36mhelp[0m: [1mProperty Synopsis[0m
|
||||
[1m/ui/theme-defs/invalid-theme/styles/text/color[0m [4m#hex|color_name[0m
|
||||
[1mDescription[0m
|
||||
The foreground color value for this style. The value can be the name of an xterm color, the hexadecimal value, or a theme variable reference.
|
||||
[1mExamples[0m
|
||||
#fff
|
||||
Green
|
||||
$black
|
||||
[1m[31m✘ error[0m: missing value for property “[1m/log/annotations/org.lnav.test.no-condition/condition[0m”
|
||||
[1m[31mreason[0m: SQL expression is invalid
|
||||
[1m[31m | [0m [1m[31mreason[0m: incomplete input
|
||||
@ -70,15 +82,3 @@
|
||||
[1m/log/annotations/org.lnav.test.no-handler/handler[0m [4m<script>[0m
|
||||
[1mDescription[0m
|
||||
The script to execute to generate the annotation content. A JSON object with the log message content will be sent to the script on the standard input
|
||||
[1m[31m✘ error[0m: invalid value for property “[1m/ui/theme-defs/invalid-theme/styles/text/color[0m”
|
||||
[1m[31mreason[0m: invalid color -- “InvalidColor”
|
||||
[1m[31m | [0m [1m[31mreason[0m: Unknown color: 'InvalidColor'. See https://jonasjacek.github.io/colors/ for a list of supported color names
|
||||
[36m --> [0m[1m{test_dir}/bad-config2/configs/invalid-theme/config.json[0m:8
|
||||
[36m =[0m [36mhelp[0m: [1mProperty Synopsis[0m
|
||||
[1m/ui/theme-defs/invalid-theme/styles/text/color[0m [4m#hex|color_name[0m
|
||||
[1mDescription[0m
|
||||
The foreground color value for this style. The value can be the name of an xterm color, the hexadecimal value, or a theme variable reference.
|
||||
[1mExamples[0m
|
||||
#fff
|
||||
Green
|
||||
$black
|
||||
|
Loading…
Reference in New Issue
Block a user