all: remove thread_local feature
This commit is contained in:
parent
0c3c03b130
commit
53aa762239
9 changed files with 82 additions and 77 deletions
|
|
@ -13,8 +13,9 @@ use {
|
|||
|
||||
static LEVEL: AtomicUsize = AtomicUsize::new(Level::Info as usize);
|
||||
|
||||
#[thread_local]
|
||||
static FILE: CloneCell<Option<Rc<OwnedFd>>> = CloneCell::new(None);
|
||||
thread_local! {
|
||||
static FILE: CloneCell<Option<Rc<OwnedFd>>> = CloneCell::new(None);
|
||||
}
|
||||
|
||||
pub fn install() {
|
||||
log::set_logger(&Logger).unwrap();
|
||||
|
|
@ -27,11 +28,11 @@ pub fn set_level(level: Level) {
|
|||
}
|
||||
|
||||
pub fn set_file(file: Rc<OwnedFd>) {
|
||||
FILE.set(Some(file));
|
||||
FILE.with(|f| f.set(Some(file)));
|
||||
}
|
||||
|
||||
pub fn unset_file() {
|
||||
FILE.set(None);
|
||||
FILE.with(|f| f.set(None));
|
||||
}
|
||||
|
||||
struct Logger;
|
||||
|
|
@ -65,7 +66,7 @@ impl Log for Logger {
|
|||
record.args(),
|
||||
)
|
||||
};
|
||||
let mut fd = match FILE.get() {
|
||||
let mut fd = match FILE.with(|f| f.get()) {
|
||||
Some(f) => f.borrow(),
|
||||
_ => Fd::new(2),
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue