show tid on log

toolchain_update
WangRunji 6 years ago
parent 2653069a43
commit d28f54ce32

2
kernel/Cargo.lock generated

@ -411,7 +411,7 @@ dependencies = [
[[package]]
name = "rcore-thread"
version = "0.1.0"
source = "git+https://github.com/rcore-os/rcore-thread#fd972c7e3aa2b7618f625f143655c16adfd2ca78"
source = "git+https://github.com/rcore-os/rcore-thread#77e8e0778154734ee59525e043caab6339e14d75"
dependencies = [
"deque 0.3.2 (git+https://github.com/rcore-os/deque.git?branch=no_std)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",

@ -3,6 +3,7 @@ use core::fmt;
use lazy_static::lazy_static;
use log::{self, Level, LevelFilter, Log, Metadata, Record};
use crate::processor;
use crate::sync::SpinNoIrqLock as Mutex;
use crate::util::color::ConsoleColor;
@ -63,12 +64,17 @@ impl Log for SimpleLogger {
true
}
fn log(&self, record: &Record) {
static DISABLED_TARGET: &[&str] = &[];
if self.enabled(record.metadata()) && !DISABLED_TARGET.contains(&record.target()) {
// let target = record.target();
// let begin = target.as_bytes().iter().rposition(|&c| c == b':').map(|i| i + 1).unwrap_or(0);
if !self.enabled(record.metadata()) {
return;
}
if let Some(tid) = processor().tid_option() {
print_in_color(
format_args!("[{:>5}][{}] {}\n", record.level(), tid, record.args()),
ConsoleColor::from(record.level()),
);
} else {
print_in_color(
format_args!("[{:>5}] {}\n", record.level(), record.args()),
format_args!("[{:>5}][-] {}\n", record.level(), record.args()),
ConsoleColor::from(record.level()),
);
}

Loading…
Cancel
Save