Skip to content

Commit d123df2

Browse files
committed
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.
1 parent 6c12ca3 commit d123df2

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

src/libstd/logging.rs

-10
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,6 @@ pub fn log_type<T>(level: u32, object: &T) {
8585
fn newsched_log_str(msg: ~str) {
8686
use rt::task::Task;
8787
use rt::local::Local;
88-
use str::StrSlice;
89-
use container::Container;
90-
91-
// Truncate the string
92-
let buf_bytes = 256;
93-
let msg = if msg.len() > buf_bytes {
94-
msg.slice(0, buf_bytes) + "[...]"
95-
} else {
96-
msg
97-
};
9888

9989
unsafe {
10090
match Local::try_unsafe_borrow::<Task>() {

src/libstd/rt/logging.rs

+17-4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use either::*;
1212
use libc;
13+
use str::StrSlice;
1314

1415
pub trait Logger {
1516
fn log(&mut self, msg: Either<~str, &'static str>);
@@ -35,10 +36,22 @@ impl Logger for StdErrLogger {
3536
s
3637
}
3738
};
38-
let dbg = ::libc::STDERR_FILENO as ::io::fd_t;
39-
dbg.write_str(s);
40-
dbg.write_str("\n");
41-
dbg.flush();
39+
40+
// Truncate the string
41+
let buf_bytes = 256;
42+
if s.len() > buf_bytes {
43+
let s = s.slice(0, buf_bytes) + "[...]";
44+
print(s);
45+
} else {
46+
print(s)
47+
};
48+
49+
fn print(s: &str) {
50+
let dbg = ::libc::STDERR_FILENO as ::io::fd_t;
51+
dbg.write_str(s);
52+
dbg.write_str("\n");
53+
dbg.flush();
54+
}
4255
}
4356
}
4457

0 commit comments

Comments
 (0)