Skip to content

Commit e1dbe9c

Browse files
committed
---
yaml --- r: 147451 b: refs/heads/try2 c: 7627081 h: refs/heads/master i: 147449: 1c79b79 147447: 6af804a v: v3
1 parent 7ea4245 commit e1dbe9c

File tree

2 files changed

+12
-22
lines changed

2 files changed

+12
-22
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: dd19785f963fd1045e53447add17ab36ca41fc79
8+
refs/heads/try2: 76270816d527bfceef64bf6cbdc64f985ca73eba
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libstd/logging.rs

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -118,26 +118,16 @@ pub static ERROR: u32 = 1;
118118
/// It is not recommended to call this function directly, rather it should be
119119
/// invoked through the logging family of macros.
120120
pub fn log(_level: u32, args: &fmt::Arguments) {
121-
unsafe {
122-
let optional_task: Option<*mut Task> = Local::try_unsafe_borrow();
123-
match optional_task {
124-
Some(local) => {
125-
// Lazily initialize the local task's logger
126-
match (*local).logger {
127-
// Use the available logger if we have one
128-
Some(ref mut logger) => { logger.log(args); }
129-
None => {
130-
let mut logger = StdErrLogger::new();
131-
logger.log(args);
132-
(*local).logger = Some(logger);
133-
}
134-
}
135-
}
136-
// If there's no local task, then always log to stderr
137-
None => {
138-
let mut logger = StdErrLogger::new();
139-
logger.log(args);
140-
}
141-
}
121+
let mut logger = {
122+
let mut task = Local::borrow(None::<Task>);
123+
task.get().logger.take()
124+
};
125+
126+
if logger.is_none() {
127+
logger = Some(StdErrLogger::new());
142128
}
129+
logger.get_mut_ref().log(args);
130+
131+
let mut task = Local::borrow(None::<Task>);
132+
task.get().logger = logger;
143133
}

0 commit comments

Comments
 (0)