Skip to content

Commit 7920732

Browse files
committed
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.
1 parent f5f36e8 commit 7920732

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/libcore/core.rc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
export box, char, float, bessel, f32, f64, int, str, ptr;
1111
export uint, u8, u32, u64, vec, bool;
1212
export either, option, result;
13-
export ctypes, sys, unsafe, comm, task;
13+
export ctypes, sys, unsafe, comm, task, logging;
1414
export extfmt;
1515
export math;
1616

@@ -52,6 +52,7 @@ mod sys;
5252
mod unsafe;
5353
mod comm;
5454
mod task;
55+
mod logging;
5556

5657
// Compiler support modules
5758

src/libcore/logging.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#[doc = "Logging"];
2+
3+
export console_on, console_off;
4+
5+
#[nolink]
6+
native mod rustrt {
7+
fn rust_log_console_on();
8+
fn rust_log_console_off();
9+
}
10+
11+
#[doc = "Turns on logging to stdout globally"]
12+
fn console_on() {
13+
rustrt::rust_log_console_on();
14+
}
15+
16+
#[doc(
17+
brief =
18+
"Turns off logging to stdout globally",
19+
desc =
20+
"Turns off the console unless the user has overridden the \
21+
runtime environment's logging spec, e.g. by setting \
22+
the RUST_LOG environment variable"
23+
)]
24+
fn console_off() {
25+
rustrt::rust_log_console_off();
26+
}

0 commit comments

Comments
 (0)