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/logging.rs | |
| parent | 1b7c99655f300aa0b8ba216cd2029dc588c3ef88 (diff) | |
std: Make console log off/on controls work with newsched
Diffstat (limited to 'src/libstd/logging.rs')
| -rw-r--r-- | src/libstd/logging.rs | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/libstd/logging.rs b/src/libstd/logging.rs index c2f854179b8..743b71e33ea 100644 --- a/src/libstd/logging.rs +++ b/src/libstd/logging.rs @@ -11,13 +11,20 @@ //! Logging use option::*; +use os; use either::*; +use rt; +use rt::OldTaskContext; use rt::logging::{Logger, StdErrLogger}; /// Turns on logging to stdout globally pub fn console_on() { - unsafe { - rustrt::rust_log_console_on(); + if rt::context() == OldTaskContext { + unsafe { + rustrt::rust_log_console_on(); + } + } else { + rt::logging::console_on(); } } @@ -29,8 +36,17 @@ pub fn console_on() { * the RUST_LOG environment variable */ pub fn console_off() { - unsafe { - rustrt::rust_log_console_off(); + // If RUST_LOG is set then the console can't be turned off + if os::getenv("RUST_LOG").is_some() { + return; + } + + if rt::context() == OldTaskContext { + unsafe { + rustrt::rust_log_console_off(); + } + } else { + rt::logging::console_off(); } } |
