fern
fern copied to clipboard
Feature Request: Log string configuration
Basically, i'd like to request the ability to use logging strings like main=trace,catgirl_engine=trace which the pretty_env_logger and android_logger both support. this is brought to you by https://github.com/iamcodemaker/console_log/issues/9
i want my users to be able to configure it with a string
I use the config crate to read logging settings and then configure logging based on those values. config parses them into a struct:
#[derive(Serialize, Deserialize, PartialEq, Clone, Debug)]
pub struct LoggingTarget {
pub target: String,
pub level: log::Level,
}
I then loop over the struct and apply the filters to the builder before calling apply():
match &self.targets {
Some(targets) => {
for target in targets {
fern = fern.level_for(
target.target.clone(),
target.level.to_level_filter().clone(),
);
}
}
None => {}
}