fix(log): 修复pr #814 的问题 (#821)

This commit is contained in:
LoGin 2024-05-16 17:32:39 +08:00 committed by GitHub
parent 2eab6dd743
commit 0897bd8e75
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 14 deletions

View File

@ -40,7 +40,7 @@ macro_rules! define_unified_initializer_slice {
static $name: [::unified_init::UnifiedInitializer] = [..];
};
() => {
compile_kerror!(
compile_error!(
"define_unified_initializer_slice! requires at least one argument: slice_name"
);
};
@ -54,7 +54,7 @@ macro_rules! define_public_unified_initializer_slice {
pub static $name: [::unified_init::UnifiedInitializer] = [..];
};
() => {
compile_kerror!(
compile_error!(
"define_unified_initializer_slice! requires at least one argument: slice_name"
);
};

View File

@ -871,9 +871,7 @@ macro_rules! define_filesystem_maker_slice {
pub static $name: [FileSystemMaker] = [..];
};
() => {
compile_kerror!(
"define_filesystem_maker_slice! requires at least one argument: slice_name"
);
compile_error!("define_filesystem_maker_slice! requires at least one argument: slice_name");
};
}

View File

@ -90,10 +90,10 @@ impl Logger {
/// 内核自定义日志器
///
/// todo: 完善他的功能并且逐步把kinfo等宏迁移到这个logger上面来。
struct CustomLogger;
/// todo: https://github.com/DragonOS-Community/DragonOS/issues/762
struct KernelLogger;
impl Log for CustomLogger {
impl Log for KernelLogger {
fn enabled(&self, _metadata: &log::Metadata) -> bool {
// 这里可以自定义日志过滤规则
true
@ -112,10 +112,10 @@ impl Log for CustomLogger {
}
}
impl CustomLogger {
impl KernelLogger {
fn iodisplay(record: &log::Record) {
match record.level() {
Level::Debug | Level::Info => {
Level::Debug | Level::Info | Level::Trace => {
write!(PrintkWriter, "[ {} ] ", record.level(),)
}
Level::Error => {
@ -124,9 +124,6 @@ impl CustomLogger {
Level::Warn => {
write!(PrintkWriter, "\x1B[1;33m[ WARN ] \x1B[0m",)
}
Level::Trace => {
todo!()
}
}
.unwrap();
writeln!(
@ -185,7 +182,7 @@ impl CustomLogger {
}
pub fn early_init_logging() {
log::set_logger(&CustomLogger).unwrap();
log::set_logger(&KernelLogger).unwrap();
log::set_max_level(log::LevelFilter::Debug);
info!("Logging initialized");
}