Skip to content

Commit

Permalink
[0.28.5]
Browse files Browse the repository at this point in the history
  • Loading branch information
emabee committed Jun 21, 2024
1 parent 9b745fd commit 43f1370
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 20 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this
project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.28.5] - 2024-06-21

Remove unnecessary dependency to `is-terminal`.

Add impl `From<LevelFilter>` for `LogSpecification`.

Kudos to [Oakchris1955](https://github.com/Oakchris1955).

## [0.28.4] - 2024-06-14

Fix [issue #162](https://github.com/emabee/flexi_logger/issues/162)
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "flexi_logger"
version = "0.28.4"
version = "0.28.5"
authors = ["emabee <[email protected]>"]
categories = ["development-tools::debugging"]
description = """
Expand Down
2 changes: 1 addition & 1 deletion examples/colors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ fn main() {

#[cfg(feature = "colors")]
{
use std::io::IsTerminal;
use nu_ansi_term::Color;
use std::io::IsTerminal;

for i in 0..=255 {
println!("{}: {}", i, Color::Fixed(i).paint(i.to_string()));
Expand Down
4 changes: 0 additions & 4 deletions scripts/qualify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,24 @@ fn main() {
std::fs::remove_file("Cargo.lock").ok();
run_command!("cargo build");
run_command!("cargo build --no-default-features");
#[rustfmt::skip]
run_command!("cargo build --all-features");
run_command!("cargo build --release");
run_command!("cargo build --release --all-features");

// Clippy in important variants
run_command!("cargo clippy -- -D warnings");
run_command!("cargo clippy --all-features -- -D warnings");
#[rustfmt::skip]
run_command!("cargo +nightly clippy --all-targets --all-features -- -D warnings");

// Run tests in important variants
run_command!("cargo +1.70.0 test --all-features");
run_command!("cargo test --release --all-features");
run_command!("cargo test --no-default-features");
run_command!("cargo test --release");
#[rustfmt::skip]
run_command!("cargo test --release --features specfile_without_notification");

// doc
run_command!("cargo +nightly test --all-features --doc");
#[rustfmt::skip]
run_command!("cargo +nightly doc --all-features --no-deps --open");

// check version consistency
Expand Down
10 changes: 5 additions & 5 deletions src/code_examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ and call `start()` immediately:
# Ok(())}
```

- Combine both options:
- Combine both options, with env having precendence over the given parameter value:

```rust
# use flexi_logger::{Logger,FlexiLoggerError};
Expand All @@ -45,11 +45,11 @@ and call `start()` immediately:
# Ok(())}
```

or, even shorter, use:
or, even shorter, use:

```rust
flexi_logger::init();
```
```rust
flexi_logger::init();
```

After that, you just use the log-macros from the log crate. Those log lines that match the
log specification are then written to the default output channel (stderr).
Expand Down
2 changes: 2 additions & 0 deletions src/log_specification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,12 +449,14 @@ impl std::fmt::Display for LogSpecification {
Ok(())
}
}

impl std::convert::TryFrom<&str> for LogSpecification {
type Error = FlexiLoggerError;
fn try_from(value: &str) -> Result<Self, Self::Error> {
LogSpecification::parse(value)
}
}

impl std::convert::TryFrom<&String> for LogSpecification {
type Error = FlexiLoggerError;
fn try_from(value: &String) -> Result<Self, Self::Error> {
Expand Down
31 changes: 22 additions & 9 deletions src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ use crate::{
LoggerHandle, Naming, WriteMode,
};

use std::io::IsTerminal;
use log::LevelFilter;
#[cfg(feature = "specfile")]
use std::sync::Mutex;
use std::{
collections::HashMap,
io::IsTerminal,
path::PathBuf,
sync::{Arc, RwLock},
time::Duration,
Expand Down Expand Up @@ -80,9 +80,24 @@ enum LogTarget {
/// loglevel-specification.
impl Logger {
/// Creates a Logger that you provide with an explicit [`LogSpecification`].
///
/// ## Examples
///
/// ```rust
/// use log::LevelFilter;
/// use flexi_logger::Logger;
/// let logger = Logger::with(LevelFilter::Info).start().unwrap();
/// ```
///
/// ```rust
/// use flexi_logger::{Logger, LogSpecification};
/// let logger = Logger::with(
/// LogSpecification::parse("info, critical_mod = trace").unwrap()
/// ).start().unwrap();
/// ```
#[must_use]
pub fn with(logspec: LogSpecification) -> Self {
Self::from_spec_and_errs(logspec)
pub fn with(logspec: impl Into<LogSpecification>) -> Self {
Self::from_spec_and_errs(logspec.into())
}

/// Creates a Logger that reads the [`LogSpecification`] from a `String` or `&str`.
Expand Down Expand Up @@ -134,13 +149,11 @@ impl Logger {
format_for_file: default_format,

#[cfg(feature = "colors")]
format_for_stdout: AdaptiveFormat::Default.format_function(
std::io::stdout().is_terminal()
),
format_for_stdout: AdaptiveFormat::Default
.format_function(std::io::stdout().is_terminal()),
#[cfg(feature = "colors")]
format_for_stderr: AdaptiveFormat::Default.format_function(
std::io::stderr().is_terminal()
),
format_for_stderr: AdaptiveFormat::Default
.format_function(std::io::stderr().is_terminal()),

#[cfg(not(feature = "colors"))]
format_for_stdout: default_format,
Expand Down

0 comments on commit 43f1370

Please sign in to comment.