Skip to content

Commit

Permalink
add configure method, to enable users to own a valid configured insta…
Browse files Browse the repository at this point in the history
…nce before calling
  • Loading branch information
twiby committed Nov 21, 2023
1 parent 5965c06 commit 58e6c75
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,8 @@ impl SimpleLogger {
self
}

/// 'Init' the actual logger, instantiate it and configure it,
/// this method MUST be called in order for the logger to be effective.
pub fn init(mut self) -> Result<(), SetLoggerError> {
/// Configure the logger
pub fn configure(&mut self) {
#[cfg(all(windows, feature = "colored"))]
set_up_color_terminal();

Expand All @@ -358,8 +357,13 @@ impl SimpleLogger {
.map(|lvl| lvl.max(self.default_level))
.unwrap_or(self.default_level);
log::set_max_level(max_level);
log::set_boxed_logger(Box::new(self))?;
Ok(())
}

/// 'Init' the actual logger and instantiate it,
/// this method MUST be called in order for the logger to be effective.
pub fn init(mut self) -> Result<(), SetLoggerError> {
self.configure();
log::set_boxed_logger(Box::new(self))
}
}

Expand Down

0 comments on commit 58e6c75

Please sign in to comment.