logging-options 0.1.0

Reusable `clap` options for logging (e.g. `--quiet` vs `--debug`) with pluggable logging providers.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use clap::Args;

use crate::Verbosity;
use crate::backend::LoggingOptions;

/// A bundle of [clap::Args] for console applications, allowing logging to stderr or a file
#[derive(Args)]
pub struct StandardConsole {
    #[clap(flatten)]
    verbosity: Verbosity,
}

impl LoggingOptions<env_logger::Logger> for StandardConsole {
    fn configure(&self, builder: env_logger::Builder) -> env_logger::Builder {
        self.verbosity.configure(builder)
    }
}