Prettify log output

master
WangRunji 6 years ago
parent 4914d22f44
commit b1a3695dfb

@ -4,7 +4,7 @@ use core::fmt;
use spin::Mutex; use spin::Mutex;
use volatile::Volatile; use volatile::Volatile;
use x86_64::instructions::port::Port; use x86_64::instructions::port::Port;
use io::Color; use logging::Color;
pub const VGA_BUFFER: Unique<VgaBuffer> = unsafe { pub const VGA_BUFFER: Unique<VgaBuffer> = unsafe {
Unique::new_unchecked((KERNEL_OFFSET + 0xb8000) as *mut _) Unique::new_unchecked((KERNEL_OFFSET + 0xb8000) as *mut _)

@ -58,7 +58,7 @@ pub use arch::other_main;
use linked_list_allocator::LockedHeap; use linked_list_allocator::LockedHeap;
#[macro_use] // print! #[macro_use] // print!
mod io; mod logging;
mod memory; mod memory;
mod lang; mod lang;
mod util; mod util;
@ -89,7 +89,7 @@ fn timer_interrupt() {
#[no_mangle] #[no_mangle]
#[cfg(target_arch = "riscv")] #[cfg(target_arch = "riscv")]
pub extern fn rust_main() -> ! { pub extern fn rust_main() -> ! {
io::init(); logging::init();
arch::init(); arch::init();
process::init(); process::init();
info!("RISCV init end"); info!("RISCV init end");
@ -104,7 +104,7 @@ pub extern "C" fn rust_main(multiboot_information_address: usize) -> ! {
// ATTENTION: we have a very small stack and no guard page // ATTENTION: we have a very small stack and no guard page
println!("Hello World{}", "!"); println!("Hello World{}", "!");
io::init(); logging::init();
arch::init(multiboot_information_address); arch::init(multiboot_information_address);
process::init(); process::init();

@ -17,7 +17,7 @@ pub fn init() {
macro_rules! print { macro_rules! print {
($($arg:tt)*) => ({ ($($arg:tt)*) => ({
$crate::io::print(format_args!($($arg)*)); $crate::logging::print(format_args!($($arg)*));
}); });
} }
@ -84,7 +84,9 @@ impl Log for SimpleLogger {
"rust_ucore::process::scheduler::rr", "rust_ucore::process::scheduler::rr",
]; ];
if self.enabled(record.metadata()) && !DISABLED_TARGET.contains(&record.target()) { if self.enabled(record.metadata()) && !DISABLED_TARGET.contains(&record.target()) {
print_in_color(format_args!("[{}] {}\n", record.target(), record.args()), Color::from(record.level())); // let target = record.target();
// let begin = target.as_bytes().iter().rposition(|&c| c == b':').map(|i| i + 1).unwrap_or(0);
print_in_color(format_args!("[{:>5}] {}\n", record.level(), record.args()), Color::from(record.level()));
} }
} }
fn flush(&self) {} fn flush(&self) {}
Loading…
Cancel
Save