about summary refs log tree commit diff
path: root/src/libstd/rt
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 /src/libstd/rt
parent6c12ca3ac2d0db3f9636e16fc5a507a12f313e7f (diff)
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.
Diffstat (limited to 'src/libstd/rt')
-rw-r--r--src/libstd/rt/logging.rs21
1 files changed, 17 insertions, 4 deletions
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();
+        }
     }
 }