diff options
| author | Brian Anderson <banderson@mozilla.com> | 2013-06-21 16:52:07 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2013-06-21 16:52:07 -0700 |
| commit | 95eb01957bf23922abdf083f677c6c2d6927713a (patch) | |
| tree | 5c0fdfe373b011f5e72cf13f1547fc3aac67921d /src/libstd/rt | |
| parent | 1b7c99655f300aa0b8ba216cd2029dc588c3ef88 (diff) | |
| download | rust-95eb01957bf23922abdf083f677c6c2d6927713a.tar.gz rust-95eb01957bf23922abdf083f677c6c2d6927713a.zip | |
std: Make console log off/on controls work with newsched
Diffstat (limited to 'src/libstd/rt')
| -rw-r--r-- | src/libstd/rt/logging.rs | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/libstd/rt/logging.rs b/src/libstd/rt/logging.rs index a0d05397689..84186180aa6 100644 --- a/src/libstd/rt/logging.rs +++ b/src/libstd/rt/logging.rs @@ -9,6 +9,7 @@ // except according to those terms. use either::*; +use libc; pub trait Logger { fn log(&mut self, msg: Either<~str, &'static str>); @@ -20,6 +21,10 @@ impl Logger for StdErrLogger { fn log(&mut self, msg: Either<~str, &'static str>) { use io::{Writer, WriterUtil}; + if !should_log_console() { + return; + } + let s: &str = match msg { Left(ref s) => { let s: &str = *s; @@ -44,7 +49,6 @@ pub fn init(crate_map: *u8) { use str; use ptr; use option::{Some, None}; - use libc::c_char; let log_spec = os::getenv("RUST_LOG"); match log_spec { @@ -61,8 +65,16 @@ pub fn init(crate_map: *u8) { } } } +} - extern { - fn rust_update_log_settings(crate_map: *u8, settings: *c_char); - } +pub fn console_on() { unsafe { rust_log_console_on() } } +pub fn console_off() { unsafe { rust_log_console_off() } } +fn should_log_console() -> bool { unsafe { rust_should_log_console() != 0 } } + +extern { + fn rust_update_log_settings(crate_map: *u8, settings: *libc::c_char); + fn rust_log_console_on(); + fn rust_log_console_off(); + fn rust_should_log_console() -> libc::uintptr_t; } + |
