Skip to content

Commit

Permalink
Merge pull request #147 from KodrAus/cargo/0.7.1
Browse files Browse the repository at this point in the history
Prepare for 0.7.1 release
  • Loading branch information
KodrAus authored Oct 17, 2019
2 parents 87496cf + e4a203b commit 68a1700
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 30 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "env_logger"
edition = "2018"
version = "0.7.0" # remember to update html_root_url
version = "0.7.1" # remember to update html_root_url
authors = ["The Rust Project Developers"]
license = "MIT/Apache-2.0"
readme = "README.md"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ It must be added along with `log` to the project dependencies:
```toml
[dependencies]
log = "0.4.0"
env_logger = "0.7.0"
env_logger = "0.7.1"
```

`env_logger` must be initialized as early as possible in the project. After it's initialized, you can use the `log` macros to do actual logging.
Expand Down Expand Up @@ -53,7 +53,7 @@ Tests can use the `env_logger` crate to see log messages generated during that t
log = "0.4.0"

[dev-dependencies]
env_logger = "0.7.0"
env_logger = "0.7.1"
```

```rust
Expand Down
56 changes: 29 additions & 27 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@
#![doc(
html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://www.rust-lang.org/static/images/favicon.ico",
html_root_url = "https://docs.rs/env_logger/0.7.0"
html_root_url = "https://docs.rs/env_logger/0.7.1"
)]
#![cfg_attr(test, deny(warnings))]
// When compiled for the rustc compiler itself we want to make sure that this is
Expand Down Expand Up @@ -808,41 +808,43 @@ impl Log for Logger {
}

let print = |formatter: &mut Formatter, record: &Record| {
let _ = (self.format)(formatter, record)
.and_then(|_| formatter.print(&self.writer));
let _ =
(self.format)(formatter, record).and_then(|_| formatter.print(&self.writer));

// Always clear the buffer afterwards
formatter.clear();
};

let printed = FORMATTER.try_with(|tl_buf| {
match tl_buf.try_borrow_mut() {
// There are no active borrows of the buffer
Ok(mut tl_buf) => match *tl_buf {
// We have a previously set formatter
Some(ref mut formatter) => {
// Check the buffer style. If it's different from the logger's
// style then drop the buffer and recreate it.
if formatter.write_style() != self.writer.write_style() {
*formatter = Formatter::new(&self.writer);
let printed = FORMATTER
.try_with(|tl_buf| {
match tl_buf.try_borrow_mut() {
// There are no active borrows of the buffer
Ok(mut tl_buf) => match *tl_buf {
// We have a previously set formatter
Some(ref mut formatter) => {
// Check the buffer style. If it's different from the logger's
// style then drop the buffer and recreate it.
if formatter.write_style() != self.writer.write_style() {
*formatter = Formatter::new(&self.writer);
}

print(formatter, record);
}
// We don't have a previously set formatter
None => {
let mut formatter = Formatter::new(&self.writer);
print(&mut formatter, record);

print(formatter, record);
}
// We don't have a previously set formatter
None => {
let mut formatter = Formatter::new(&self.writer);
print(&mut formatter, record);

*tl_buf = Some(formatter);
*tl_buf = Some(formatter);
}
},
// There's already an active borrow of the buffer (due to re-entrancy)
Err(_) => {
print(&mut Formatter::new(&self.writer), record);
}
}
// There's already an active borrow of the buffer (due to re-entrancy)
Err(_) => {
print(&mut Formatter::new(&self.writer), record);
}
}
}).is_ok();
})
.is_ok();

if !printed {
// The thread-local storage was not available (because its
Expand Down

0 comments on commit 68a1700

Please sign in to comment.