rustbasic_core/support/
log.rs1use crate::logger::{log, Level};
2
3pub struct Log;
4
5impl Log {
6 pub fn info(msg: impl AsRef<str>) {
8 log(Level::Info, msg.as_ref());
9 }
10
11 pub fn debug(msg: impl AsRef<str>) {
13 log(Level::Debug, msg.as_ref());
14 }
15
16 pub fn warning(msg: impl AsRef<str>) {
18 log(Level::Warn, msg.as_ref());
19 }
20
21 pub fn error(msg: impl AsRef<str>) {
23 log(Level::Error, msg.as_ref());
24 }
25
26 pub fn info_with(msg: impl AsRef<str>, context: &serde_json::Value) {
28 let msg_with_ctx = format!("{} - Context: {}", msg.as_ref(), context);
29 log(Level::Info, &msg_with_ctx);
30 }
31
32 pub fn debug_with(msg: impl AsRef<str>, context: &serde_json::Value) {
34 let msg_with_ctx = format!("{} - Context: {}", msg.as_ref(), context);
35 log(Level::Debug, &msg_with_ctx);
36 }
37
38 pub fn warning_with(msg: impl AsRef<str>, context: &serde_json::Value) {
40 let msg_with_ctx = format!("{} - Context: {}", msg.as_ref(), context);
41 log(Level::Warn, &msg_with_ctx);
42 }
43
44 pub fn error_with(msg: impl AsRef<str>, context: &serde_json::Value) {
46 let msg_with_ctx = format!("{} - Context: {}", msg.as_ref(), context);
47 log(Level::Error, &msg_with_ctx);
48 }
49}