1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use log::{self, Log, LevelFilter, Metadata, Record};
use crate::syscalls::output_debug_string;
struct Logger;
impl Log for Logger {
fn enabled(&self, _metadata: &Metadata<'_>) -> bool {
true
}
fn log(&self, record: &Record<'_>) {
let level = match record.level() {
log::Level::Error => 10,
log::Level::Warn => 30,
log::Level::Info => 50,
log::Level::Debug => 70,
log::Level::Trace => 90,
};
let _ = output_debug_string(&*format!("{}", record.args()), level, record.target());
}
fn flush(&self) {}
}
pub fn init() {
log::set_logger(&Logger)
.expect("log_impl::init to be called only once");
log::set_max_level(LevelFilter::Trace);
info!("Logging enabled");
}