提交 d123df26 编写于 作者: B Brian Anderson

std: Fix newsched logging truncation

The truncation needs to be done in the console logger in order
to catch all the logging output, and because truncation only matters
when outputting to the console.
上级 6c12ca3a
......@@ -85,16 +85,6 @@ pub fn log_type<T>(level: u32, object: &T) {
fn newsched_log_str(msg: ~str) {
use rt::task::Task;
use rt::local::Local;
use str::StrSlice;
use container::Container;
// Truncate the string
let buf_bytes = 256;
let msg = if msg.len() > buf_bytes {
msg.slice(0, buf_bytes) + "[...]"
} else {
msg
};
unsafe {
match Local::try_unsafe_borrow::<Task>() {
......
......@@ -10,6 +10,7 @@
use either::*;
use libc;
use str::StrSlice;
pub trait Logger {
fn log(&mut self, msg: Either<~str, &'static str>);
......@@ -35,10 +36,22 @@ fn log(&mut self, msg: Either<~str, &'static str>) {
s
}
};
let dbg = ::libc::STDERR_FILENO as ::io::fd_t;
dbg.write_str(s);
dbg.write_str("\n");
dbg.flush();
// Truncate the string
let buf_bytes = 256;
if s.len() > buf_bytes {
let s = s.slice(0, buf_bytes) + "[...]";
print(s);
} else {
print(s)
};
fn print(s: &str) {
let dbg = ::libc::STDERR_FILENO as ::io::fd_t;
dbg.write_str(s);
dbg.write_str("\n");
dbg.flush();
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册