-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
243 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
root = true | ||
|
||
[*.rs] | ||
indent_style = space | ||
indent_size = 2 | ||
max_line_length = 160 | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
message_keys = ["short_message", "msg", "message"] | ||
time_keys = ["timestamp", "time", "@timestamp"] | ||
level_keys = ["level", "severity", "log.level", "loglevel"] | ||
main_line_format = "{{bold(fixed_size 19 fblog_timestamp)}} {{level_style (uppercase (fixed_size 5 fblog_level))}}:{{bold(color_rgb 138 43 226 fblog_prefix)}} {{fblog_message}}" | ||
additional_value_format = "{{bold (color_rgb 150 150 150 (fixed_size 25 key))}}: {{value}}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use crate::template::{DEFAULT_ADDITIONAL_VALUE_FORMAT, DEFAULT_MAIN_LINE_FORMAT}; | ||
|
||
fn default_message_keys() -> Vec<String> { | ||
vec!["short_message".to_string(), "msg".to_string(), "message".to_string()] | ||
} | ||
|
||
fn default_time_keys() -> Vec<String> { | ||
vec!["timestamp".to_string(), "time".to_string(), "@timestamp".to_string()] | ||
} | ||
|
||
fn default_level_keys() -> Vec<String> { | ||
vec!["level".to_string(), "severity".to_string(), "log.level".to_string(), "loglevel".to_string()] | ||
} | ||
|
||
fn default_main_line_format() -> String { | ||
DEFAULT_MAIN_LINE_FORMAT.to_string() | ||
} | ||
|
||
fn default_additional_value_format() -> String { | ||
DEFAULT_ADDITIONAL_VALUE_FORMAT.to_string() | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug)] | ||
pub struct Config { | ||
#[serde(default = "default_message_keys")] | ||
pub message_keys: Vec<String>, | ||
|
||
#[serde(default = "default_time_keys")] | ||
pub time_keys: Vec<String>, | ||
|
||
#[serde(default = "default_level_keys")] | ||
pub level_keys: Vec<String>, | ||
|
||
#[serde(default = "default_main_line_format")] | ||
pub main_line_format: String, | ||
|
||
#[serde(default = "default_additional_value_format")] | ||
pub additional_value_format: String, | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use std::fs; | ||
|
||
use super::*; | ||
|
||
#[test] | ||
fn read_defaults_from_empty_config() { | ||
let config: Config = toml::from_str( | ||
r#" | ||
"#, | ||
) | ||
.unwrap(); | ||
|
||
assert_eq!(config.level_keys, default_level_keys()); | ||
assert_eq!(config.time_keys, default_time_keys()); | ||
assert_eq!(config.message_keys, default_message_keys()); | ||
assert_eq!(config.main_line_format, DEFAULT_MAIN_LINE_FORMAT); | ||
assert_eq!(config.additional_value_format, DEFAULT_ADDITIONAL_VALUE_FORMAT); | ||
|
||
let serialized_defaults = toml::to_string(&config).unwrap(); | ||
let default_config_for_documentation = fs::read_to_string("default_config.toml").unwrap(); | ||
assert_eq!(serialized_defaults, default_config_for_documentation) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ use std::io; | |
extern crate regex; | ||
|
||
mod app; | ||
mod config; | ||
mod filter; | ||
mod log; | ||
mod no_color_support; | ||
|