mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-18 00:01:24 +01:00
config options for log format and color usage
We want to be able to disable colors for complement logs (since they are likely to be opened in a text editor). There's no pressing need for alternative log formats, but I'm interested in whether the 'pretty' format will be easier for debugging. I chose to add 'log_*' options rather than making a separate 'log' section for now. There's been some discussion about trying to separate the tracing/logging stuff into more structured sections, but that can happen later.
This commit is contained in:
parent
4f041f9153
commit
a909e2079b
4 changed files with 46 additions and 4 deletions
|
|
@ -77,6 +77,10 @@ pub(crate) struct Config {
|
|||
pub(crate) trusted_servers: Vec<OwnedServerName>,
|
||||
#[serde(default = "default_log")]
|
||||
pub(crate) log: EnvFilterClone,
|
||||
#[serde(default = "true_fn")]
|
||||
pub(crate) log_colors: bool,
|
||||
#[serde(default)]
|
||||
pub(crate) log_format: LogFormat,
|
||||
#[serde(default)]
|
||||
pub(crate) turn_username: String,
|
||||
#[serde(default)]
|
||||
|
|
@ -110,6 +114,20 @@ pub(crate) enum ListenConfig {
|
|||
},
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Default, Debug, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub(crate) enum LogFormat {
|
||||
/// Use the [`tracing_subscriber::fmt::format::Pretty`] formatter
|
||||
Pretty,
|
||||
/// Use the [`tracing_subscriber::fmt::format::Full`] formatter
|
||||
#[default]
|
||||
Full,
|
||||
/// Use the [`tracing_subscriber::fmt::format::Compact`] formatter
|
||||
Compact,
|
||||
/// Use the [`tracing_subscriber::fmt::format::Json`] formatter
|
||||
Json,
|
||||
}
|
||||
|
||||
impl Display for ListenConfig {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue