about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2013-08-04 21:54:59 -0700
committerBrian Anderson <banderson@mozilla.com>2013-08-04 21:56:47 -0700
commitd123df26ff1796f4712b10290a3b6647d754a6e3 (patch)
tree47d7451739a7543ecb6703cfa3f1968090d40515
parent6c12ca3ac2d0db3f9636e16fc5a507a12f313e7f (diff)
downloadrust-d123df26ff1796f4712b10290a3b6647d754a6e3.tar.gz
rust-d123df26ff1796f4712b10290a3b6647d754a6e3.zip
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.
-rw-r--r--src/libstd/logging.rs10
-rw-r--r--src/libstd/rt/logging.rs21
2 files changed, 17 insertions, 14 deletions
diff --git a/src/libstd/logging.rs b/src/libstd/logging.rs
index c662e5997af..6e11d14aea9 100644
--- a/src/libstd/logging.rs
+++ b/src/libstd/logging.rs
@@ -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>() {
diff --git a/src/libstd/rt/logging.rs b/src/libstd/rt/logging.rs
index 11d11daebc2..9056f0d52e0 100644
--- a/src/libstd/rt/logging.rs
+++ b/src/libstd/rt/logging.rs
@@ -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 @@ impl Logger for StdErrLogger {
                 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();
+        }
     }
 }