aboutsummaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authornotgne22020-12-27 11:05:37 -0700
committernotgne22020-12-27 11:05:37 -0700
commit01ea759cf653750694201522a1b7e0d86f89a177 (patch)
treed49ec764c9d5b85a70dc18ca63ce4b2d8721192e /src/utils
parent72b04b0ae84f68a3314de32da87381097a54fbe5 (diff)
Deduplicate level to emoji pattern into make_emoji()
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/mod.rs26
1 files changed, 12 insertions, 14 deletions
diff --git a/src/utils/mod.rs b/src/utils/mod.rs
index 42c81f7..00277c8 100644
--- a/src/utils/mod.rs
+++ b/src/utils/mod.rs
@@ -19,6 +19,16 @@ macro_rules! good_panic {
}}
}
+fn make_emoji(level: log::Level) -> &'static str {
+ match level {
+ log::Level::Error => "❌",
+ log::Level::Warn => "⚠️",
+ log::Level::Info => "ℹ️",
+ log::Level::Debug => "❓",
+ log::Level::Trace => "🖊️",
+ }
+}
+
pub fn logger_formatter_activate(
w: &mut dyn std::io::Write,
_now: &mut DeferredNow,
@@ -29,13 +39,7 @@ pub fn logger_formatter_activate(
write!(
w,
"⭐ REMOTE ⭐ {0} {1} {0} {2}",
- match level {
- log::Level::Error => "❌",
- log::Level::Warn => "⚠️",
- log::Level::Info => "ℹ️",
- log::Level::Debug => "❓",
- log::Level::Trace => "🖊️",
- },
+ make_emoji(level),
style(level, level.to_string()),
record.args()
)
@@ -51,13 +55,7 @@ pub fn logger_formatter_deploy(
write!(
w,
"🚀 {0} {1} {0} {2}",
- match level {
- log::Level::Error => "❌",
- log::Level::Warn => "⚠️",
- log::Level::Info => "ℹ️",
- log::Level::Debug => "❓",
- log::Level::Trace => "🖊️",
- },
+ make_emoji(level),
style(level, level.to_string()),
record.args()
)