From 79207321ae4061e18ff71db755f42578132140fb Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Fri, 13 Jan 2012 13:20:11 -0800 Subject: [PATCH] libcore: Add core::logging::console_on/off functions These affect logging output to stdout globally, and turning the console off has no effect when overridden by RUST_LOG. --- src/libcore/core.rc | 3 ++- src/libcore/logging.rs | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/libcore/logging.rs diff --git a/src/libcore/core.rc b/src/libcore/core.rc index 4035b6e1b44..d97992da618 100644 --- a/src/libcore/core.rc +++ b/src/libcore/core.rc @@ -10,7 +10,7 @@ export box, char, float, bessel, f32, f64, int, str, ptr; export uint, u8, u32, u64, vec, bool; export either, option, result; -export ctypes, sys, unsafe, comm, task; +export ctypes, sys, unsafe, comm, task, logging; export extfmt; export math; @@ -52,6 +52,7 @@ mod sys; mod unsafe; mod comm; mod task; +mod logging; // Compiler support modules diff --git a/src/libcore/logging.rs b/src/libcore/logging.rs new file mode 100644 index 00000000000..d9c0274f390 --- /dev/null +++ b/src/libcore/logging.rs @@ -0,0 +1,26 @@ +#[doc = "Logging"]; + +export console_on, console_off; + +#[nolink] +native mod rustrt { + fn rust_log_console_on(); + fn rust_log_console_off(); +} + +#[doc = "Turns on logging to stdout globally"] +fn console_on() { + rustrt::rust_log_console_on(); +} + +#[doc( + brief = + "Turns off logging to stdout globally", + desc = + "Turns off the console unless the user has overridden the \ + runtime environment's logging spec, e.g. by setting \ + the RUST_LOG environment variable" +)] +fn console_off() { + rustrt::rust_log_console_off(); +} \ No newline at end of file