Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions kernel/crates/unified-init/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
);
};
Expand All @@ -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"
);
};
Expand Down
4 changes: 1 addition & 3 deletions kernel/src/filesystem/vfs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
};
}

Expand Down
15 changes: 6 additions & 9 deletions kernel/src/libs/printk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 => {
Expand All @@ -124,9 +124,6 @@ impl CustomLogger {
Level::Warn => {
write!(PrintkWriter, "\x1B[1;33m[ WARN ] \x1B[0m",)
}
Level::Trace => {
todo!()
}
}
.unwrap();
writeln!(
Expand Down Expand Up @@ -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");
}
Loading