This commit is contained in:
@@ -171,7 +171,7 @@ impl Config {
|
||||
self.keys.extend(settings);
|
||||
}
|
||||
|
||||
pub fn log_errors(&self, use_stderr: bool) {
|
||||
pub fn log_errors(&self) {
|
||||
for (key, err) in &self.errors {
|
||||
let (cause, message) = match err {
|
||||
ConfigError::Parse { error } => (
|
||||
@@ -187,15 +187,12 @@ impl Config {
|
||||
format!("Macro expansion error for setting {key:?}: {error}"),
|
||||
),
|
||||
};
|
||||
if !use_stderr {
|
||||
trc::event!(Config(cause), Details = message);
|
||||
} else {
|
||||
eprintln!("ERROR: {message}");
|
||||
}
|
||||
|
||||
trc::error!(trc::EventType::Config(cause).into_err().details(message));
|
||||
}
|
||||
}
|
||||
|
||||
pub fn log_warnings(&mut self, use_stderr: bool) {
|
||||
pub fn log_warnings(&mut self) {
|
||||
#[cfg(debug_assertions)]
|
||||
self.warn_unread_keys();
|
||||
|
||||
@@ -222,11 +219,8 @@ impl Config {
|
||||
format!("WARNING for {key:?}: {error}"),
|
||||
),
|
||||
};
|
||||
if !use_stderr {
|
||||
trc::event!(Config(cause), Details = message);
|
||||
} else {
|
||||
eprintln!("{}", message);
|
||||
}
|
||||
|
||||
trc::error!(trc::EventType::Config(cause).into_err().details(message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
use std::{
|
||||
net::{IpAddr, Ipv4Addr, Ipv6Addr},
|
||||
path::PathBuf,
|
||||
str::FromStr,
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
@@ -572,6 +573,18 @@ impl ParseValue for Rate {
|
||||
}
|
||||
}
|
||||
|
||||
impl ParseValue for trc::Level {
|
||||
fn parse_value(value: &str) -> super::Result<Self> {
|
||||
trc::Level::from_str(value).map_err(|err| format!("Invalid log level: {err}"))
|
||||
}
|
||||
}
|
||||
|
||||
impl ParseValue for trc::EventType {
|
||||
fn parse_value(value: &str) -> super::Result<Self> {
|
||||
trc::EventType::try_parse(value).ok_or_else(|| format!("Unknown event type: {value}"))
|
||||
}
|
||||
}
|
||||
|
||||
impl ParseValue for () {
|
||||
fn parse_value(_: &str) -> super::Result<Self> {
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user