Use error! instead of println! when panicking

This commit is contained in:
Yifan Wu 2023-03-28 23:42:48 +08:00
parent 0f866c4ee6
commit c4e734610c

View File

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