Skip to content

Commit fef29b6

Browse files
committed
---
yaml --- r: 96911 b: refs/heads/dist-snap c: 7627081 h: refs/heads/master i: 96909: a07399b 96907: 36ef035 96903: dad95b6 96895: b1ab6ad v: v3
1 parent 01333ac commit fef29b6

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
@@ -6,7 +6,7 @@ refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: dd19785f963fd1045e53447add17ab36ca41fc79
9+
refs/heads/dist-snap: 76270816d527bfceef64bf6cbdc64f985ca73eba
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/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)