fern icon indicating copy to clipboard operation
fern copied to clipboard

Feature Request: Log string configuration

Open lexi-the-cute opened this issue 1 year ago • 1 comments

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

lexi-the-cute avatar Mar 09 '24 04:03 lexi-the-cute

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 => {}
}

JEleniel avatar Jul 26 '25 14:07 JEleniel