diff options
author | Nathan Ringo <nathan@remexre.com> | 2024-01-16 03:02:48 -0600 |
---|---|---|
committer | Nathan Ringo <nathan@remexre.com> | 2024-01-16 03:02:48 -0600 |
commit | af0d1d5cb4d9ddb1a69ba5e8313d593d02960c88 (patch) | |
tree | f9fe1b38c6aa171177465952b1f3a6a12550dc76 /src/lib.rs | |
parent | bc91cdbc75b299a810da0fed2c09acf040620fbe (diff) |
Change logging implementation.
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -1,2 +1,21 @@ pub mod config; pub mod handlers; + +use anyhow::{Context, Result}; + +pub fn configure_logger(quiet: u8, verbose: u8) -> Result<()> { + let level = match (quiet, verbose) { + (0, 0) => Some(log::Level::Warn), + (0, 1) => Some(log::Level::Info), + (0, 2) => Some(log::Level::Debug), + (0, _) => Some(log::Level::Trace), + (1, _) => Some(log::Level::Error), + (_, _) => None, + }; + + if let Some(level) = level { + simple_logger::init_with_level(level).context("failed to configure logger")?; + } + + Ok(()) +} |