Skip to content

Commit 6b45158

Browse files
committed
---
yaml --- r: 61356 b: refs/heads/try c: 0a54bad h: refs/heads/master v: v3
1 parent 2f6e35f commit 6b45158

File tree

6 files changed

+47
-6
lines changed

6 files changed

+47
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2d28d645422c1617be58c8ca7ad9a457264ca850
5-
refs/heads/try: cc2897d559742c5f7630557975aa72c12a0eff01
5+
refs/heads/try: 0a54bad3d1d306845b04f146c2c31d4a70e9ede3
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libcore/rt/logging.rs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,34 @@ impl Logger for StdErrLogger {
3535
dbg.write_str("\n");
3636
dbg.flush();
3737
}
38-
}
38+
}
39+
40+
/// Configure logging by traversing the crate map and setting the
41+
/// per-module global logging flags based on the logging spec
42+
pub fn init(crate_map: *u8) {
43+
use os;
44+
use str;
45+
use ptr;
46+
use option::{Some, None};
47+
use libc::c_char;
48+
49+
let log_spec = os::getenv("RUST_LOG");
50+
match log_spec {
51+
Some(spec) => {
52+
do str::as_c_str(spec) |s| {
53+
unsafe {
54+
rust_update_log_settings(crate_map, s);
55+
}
56+
}
57+
}
58+
None => {
59+
unsafe {
60+
rust_update_log_settings(crate_map, ptr::null());
61+
}
62+
}
63+
}
64+
65+
extern {
66+
fn rust_update_log_settings(crate_map: *u8, settings: *c_char);
67+
}
68+
}

branches/try/src/libcore/rt/mod.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ Several modules in `core` are clients of `rt`:
6262

6363
#[doc(hidden)];
6464

65-
use libc::c_char;
6665
use ptr::Ptr;
6766

6867
/// The global (exchange) heap.
@@ -138,11 +137,13 @@ pub mod tube;
138137
/// # Return value
139138
///
140139
/// The return value is used as the process return code. 0 on success, 101 on error.
141-
pub fn start(_argc: int, _argv: **c_char, _crate_map: *u8, main: ~fn()) -> int {
140+
pub fn start(_argc: int, _argv: **u8, crate_map: *u8, main: ~fn()) -> int {
142141

143142
use self::sched::{Scheduler, Task};
144143
use self::uv::uvio::UvEventLoop;
145144

145+
init(crate_map);
146+
146147
let loop_ = ~UvEventLoop::new();
147148
let mut sched = ~Scheduler::new(loop_);
148149
let main_task = ~Task::new(&mut sched.stack_pool, main);
@@ -153,6 +154,12 @@ pub fn start(_argc: int, _argv: **c_char, _crate_map: *u8, main: ~fn()) -> int {
153154
return 0;
154155
}
155156

157+
/// One-time runtime initialization. Currently all this does is set up logging
158+
/// based on the RUST_LOG environment variable.
159+
pub fn init(crate_map: *u8) {
160+
logging::init(crate_map);
161+
}
162+
156163
/// Possible contexts in which Rust code may be executing.
157164
/// Different runtime services are available depending on context.
158165
/// Mostly used for determining if we're using the new scheduler

branches/try/src/libcore/unstable/lang.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ pub fn start(main: *u8, argc: int, argv: **c_char,
435435
return rust_start(main as *c_void, argc as c_int, argv,
436436
crate_map as *c_void) as int;
437437
} else {
438-
return do rt::start(argc, argv, crate_map) {
438+
return do rt::start(argc, argv as **u8, crate_map) {
439439
unsafe {
440440
// `main` is an `fn() -> ()` that doesn't take an environment
441441
// XXX: Could also call this as an `extern "Rust" fn` once they work

branches/try/src/rt/rust_log.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,10 @@ void update_log_settings(void* crate_map, char* settings) {
324324
free(buffer);
325325
}
326326

327+
extern "C" CDECL void
328+
rust_update_log_settings(void* crate_map, char* settings) {
329+
update_log_settings(crate_map, settings);
330+
}
327331

328332
//
329333
// Local Variables:

branches/try/src/rt/rustrt.def.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,4 +238,4 @@ rust_valgrind_stack_register
238238
rust_valgrind_stack_deregister
239239
rust_take_env_lock
240240
rust_drop_env_lock
241-
241+
rust_update_log_settings

0 commit comments

Comments
 (0)