lang_interpreter/terminal_io/
custom_logging.rs1#[cfg(feature = "wasm")]
2#[doc(hidden)]
3pub mod wasm;
4
5use std::fmt::Debug;
6use crate::terminal_io::Level;
7
8pub trait Logger: Debug {
12 fn log(&mut self, lvl: Level, time_label: &str, text: &str, tag: &str);
13}
14
15#[derive(Debug)]
19pub struct DefaultLogger;
20
21impl DefaultLogger {
22 pub fn new() -> Self {
23 Self
24 }
25}
26
27impl Default for DefaultLogger {
28 fn default() -> Self {
29 Self::new()
30 }
31}
32
33impl Logger for DefaultLogger {
34 fn log(&mut self, lvl: Level, time_label: &str, text: &str, tag: &str) {
35 println!(
36 "[{}][{}][{}]: {}",
37 lvl.name(),
38 time_label,
39 tag,
40 text,
41 );
42 }
43}