From 3fe6644faaf8dc18a1cffe2d4bac94be22c9e67e Mon Sep 17 00:00:00 2001 From: MadelynWith5Ns Date: Wed, 15 May 2024 13:22:18 -0500 Subject: [PATCH] feat(log): add Logger::quick() --- src/log.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/log.rs b/src/log.rs index 2fecab8..085dc70 100644 --- a/src/log.rs +++ b/src/log.rs @@ -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 { let timestamp = crate::time::timestamp_now();