forked from koniifer/ableos
Logging
This commit is contained in:
parent
8fbf7b5a5a
commit
b3954e3533
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -585,9 +585,9 @@ dependencies = [
|
|||
"crossbeam-queue",
|
||||
"limine",
|
||||
"linked_list_allocator",
|
||||
"log",
|
||||
"slab",
|
||||
"spin 0.9.4",
|
||||
"tracing",
|
||||
"uart_16550",
|
||||
"versioning",
|
||||
"x86_64",
|
||||
|
|
|
@ -8,7 +8,7 @@ linked_list_allocator = "0.9"
|
|||
slab = { version = "0.4", default-features = false }
|
||||
spin = "0.9"
|
||||
versioning = { git = "https://git.ablecorp.us/able/aos_userland" }
|
||||
tracing = { version = "0.1", default-features = false, features = ["attributes"] }
|
||||
log = "0.4"
|
||||
|
||||
[dependencies.crossbeam-queue]
|
||||
version = "0.3"
|
||||
|
|
|
@ -13,10 +13,9 @@ unsafe extern "C" fn _kernel_start() -> ! {
|
|||
static HDHM_REQ: LimineHhdmRequest = LimineHhdmRequest::new(0);
|
||||
static MMAP_REQ: LimineMmapRequest = LimineMmapRequest::new(0);
|
||||
|
||||
let _ = serial_fmt(format_args!(
|
||||
"Initialising AbleOS Kernel {}\r\n",
|
||||
crate::VERSION
|
||||
));
|
||||
SERIAL_CONSOLE.lock().init();
|
||||
crate::logger::init().expect("failed to set logger");
|
||||
log::info!("Initialising AKern {}", crate::VERSION);
|
||||
|
||||
memory::init_pt(VirtAddr::new(
|
||||
HDHM_REQ
|
||||
|
@ -35,7 +34,6 @@ unsafe extern "C" fn _kernel_start() -> ! {
|
|||
);
|
||||
|
||||
allocator::init_alloc().expect("tried to initialise allocator");
|
||||
SERIAL_CONSOLE.lock().init();
|
||||
|
||||
crate::kmain::kmain()
|
||||
}
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
// TODO: Tracing Subscriber serial print implementation
|
|
@ -7,7 +7,7 @@ extern crate alloc;
|
|||
|
||||
pub mod allocator;
|
||||
pub mod arch;
|
||||
pub mod debug;
|
||||
pub mod logger;
|
||||
pub mod kmain;
|
||||
pub mod task;
|
||||
|
||||
|
|
33
kernel/src/logger.rs
Normal file
33
kernel/src/logger.rs
Normal file
|
@ -0,0 +1,33 @@
|
|||
use log::{Level, SetLoggerError};
|
||||
|
||||
pub fn init() -> Result<(), SetLoggerError> {
|
||||
log::set_logger(&crate::logger::Logger)?;
|
||||
log::set_max_level(log::LevelFilter::Trace);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
struct Logger;
|
||||
impl log::Log for Logger {
|
||||
fn enabled(&self, metadata: &log::Metadata) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn log(&self, record: &log::Record) {
|
||||
let lvl = record.level();
|
||||
crate::arch::serial_fmt(format_args!(
|
||||
"\x1b[38;5;{}m{lvl}\x1b[0m [{}]: {}\r\n",
|
||||
match lvl {
|
||||
Level::Error => "160",
|
||||
Level::Warn => "172",
|
||||
Level::Info => "47",
|
||||
Level::Debug => "25",
|
||||
Level::Trace => "103",
|
||||
},
|
||||
record.module_path().unwrap_or_default(),
|
||||
record.args(),
|
||||
))
|
||||
.expect("write to serial console");
|
||||
}
|
||||
|
||||
fn flush(&self) {}
|
||||
}
|
Loading…
Reference in a new issue