poplar/
early_logger.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use alloc::string::String;
use core::fmt::Write;
use log::{Log, Metadata, Record};

pub struct EarlyLogger;

impl Log for EarlyLogger {
    fn enabled(&self, _metadata: &Metadata) -> bool {
        true
    }

    fn log(&self, record: &Record) {
        if self.enabled(record.metadata()) {
            let mut s = String::new();
            write!(s, "{}", record.args()).unwrap();
            crate::syscall::early_log(&s).unwrap();
        }
    }

    fn flush(&self) {}
}