Skip to content

Commit

Permalink
feat(log): add Logger::quick()
Browse files Browse the repository at this point in the history
  • Loading branch information
madelynwith5ns committed May 15, 2024
1 parent 9bfe234 commit 3fe6644
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,22 @@ impl Logger<'_> {
};
}

/// Quickly create a logger with the specified prefix.
/// Uses the default log level.
pub fn quick(prefix: &str) -> Logger {
return Logger {
prefix: Some(prefix),
#[cfg(debug_assertions)]
tlevel: LogLevel::DEBUG,
#[cfg(not(debug_assertions))]
tlevel: LogLevel::INFO,
#[cfg(debug_assertions)]
flevel: LogLevel::DEBUG,
#[cfg(not(debug_assertions))]
flevel: LogLevel::INFO,
}
}

/// Logging function, you'll usually want to use the macros.
pub fn log(&self, level: LogLevel, text: String) -> Option<String> {
let timestamp = crate::time::timestamp_now();
Expand Down

0 comments on commit 3fe6644

Please sign in to comment.