Skip to content

Commit

Permalink
add an option to always print some fields
Browse files Browse the repository at this point in the history
  • Loading branch information
bomgar committed Sep 27, 2024
1 parent b7dd148 commit 826b765
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions default_config.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
message_keys = ["short_message", "msg", "message"]
time_keys = ["timestamp", "time", "@timestamp"]
dump_all_exclude = []
always_print_fields = []
level_keys = ["level", "severity", "log.level", "loglevel"]
main_line_format = "{{bold(fixed_size 19 fblog_timestamp)}} {{level_style (uppercase (fixed_size 5 fblog_level))}}:{{#if fblog_prefix}} {{bold(cyan fblog_prefix)}}{{/if}} {{fblog_message}}"
additional_value_format = "{{bold (color_rgb 150 150 150 (fixed_size 25 key))}}: {{value}}"
Expand Down
9 changes: 9 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@ fn default_message_keys() -> Vec<String> {
fn default_time_keys() -> Vec<String> {
vec!["timestamp".to_string(), "time".to_string(), "@timestamp".to_string()]
}

fn default_dump_all_exclude() -> Vec<String> {
vec![]
}

fn default_always_print_fields() -> Vec<String> {
vec![]
}

fn default_level_keys() -> Vec<String> {
vec!["level".to_string(), "severity".to_string(), "log.level".to_string(), "loglevel".to_string()]
}
Expand Down Expand Up @@ -43,6 +48,9 @@ pub struct Config {
#[serde(default = "default_dump_all_exclude")]
pub dump_all_exclude: Vec<String>,

#[serde(default = "default_always_print_fields")]
pub always_print_fields: Vec<String>,

#[serde(default = "default_level_keys")]
pub level_keys: Vec<String>,

Expand Down Expand Up @@ -87,6 +95,7 @@ impl Config {
main_line_format: default_main_line_format(),
additional_value_format: default_additional_value_format(),
dump_all_exclude: default_dump_all_exclude(),
always_print_fields: default_always_print_fields(),
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/log_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl LogSettings {
time_keys: config.time_keys.clone(),
level_keys: config.level_keys.clone(),
level_map: config.level_map.clone(),
additional_values: vec![],
additional_values: config.always_print_fields.clone(),
excluded_values: config.dump_all_exclude.clone(),
dump_all: false,
with_prefix: false,
Expand Down

0 comments on commit 826b765

Please sign in to comment.