Use error! instead of println! when panicking

This commit is contained in:
Yifan Wu 2023-03-28 23:42:48 +08:00
parent e0c0ec8764
commit 70f8e7bafa

View File

@ -1,17 +1,18 @@
use crate::sbi::shutdown; use crate::sbi::shutdown;
use core::panic::PanicInfo; use core::panic::PanicInfo;
use log::*;
#[panic_handler] #[panic_handler]
fn panic(info: &PanicInfo) -> ! { fn panic(info: &PanicInfo) -> ! {
if let Some(location) = info.location() { if let Some(location) = info.location() {
println!( error!(
"[kernel] Panicked at {}:{} {}", "[kernel] Panicked at {}:{} {}",
location.file(), location.file(),
location.line(), location.line(),
info.message().unwrap() info.message().unwrap()
); );
} else { } else {
println!("[kernel] Panicked: {}", info.message().unwrap()); error!("[kernel] Panicked: {}", info.message().unwrap());
} }
shutdown(true) shutdown(true)
} }