diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 8d41a57..a3402ba 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -2,16 +2,14 @@ name: tests on: push: - branches: main pull_request: - branches: main env: CARGO_TERM_COLOR: always jobs: test: - name: Test Suite + name: Run Tests runs-on: ${{ matrix.os }} strategy: matrix: @@ -21,64 +19,26 @@ jobs: os: - ubuntu-latest - windows-latest + toolchain: + - stable + - 1.70.0 steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: ${{ matrix.rust }} - override: true - - uses: actions-rs/cargo@v1 - with: - command: build - args: --lib --bins --examples --tests --benches - - uses: actions-rs/cargo@v1 - with: - command: build - args: --lib --bins --examples --tests --benches --all-features - - uses: actions-rs/cargo@v1 - with: - command: test - - uses: actions-rs/cargo@v1 - with: - command: test - args: --no-default-features - - uses: actions-rs/cargo@v1 - with: - command: test - args: --features=colored - - uses: actions-rs/cargo@v1 - with: - command: test - args: --features=syslog-3 - - uses: actions-rs/cargo@v1 - with: - command: test - args: --features=syslog-4 - - uses: actions-rs/cargo@v1 - with: - command: test - args: --features=syslog-6 - - uses: actions-rs/cargo@v1 - with: - command: test - args: --features=syslog-7 - - uses: actions-rs/cargo@v1 - with: - command: test - args: --features=reopen-03 - - uses: actions-rs/cargo@v1 - with: - command: test - args: --features=reopen-1 - - uses: actions-rs/cargo@v1 - with: - command: test - args: --features=meta-logging-in-format - - uses: actions-rs/cargo@v1 - with: - command: test - args: --all-features + - uses: actions/checkout@v4 + - run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }} + - run: cargo build --all-targets + - run: cargo build --all-targets --no-default-features + - run: cargo build --all-targets --all-features + - run: cargo test + - run: cargo test --no-default-features + - run: cargo test --features=colored + - run: cargo test --features=syslog-3 + - run: cargo test --features=syslog-4 + - run: cargo test --features=syslog-6 + - run: cargo test --features=syslog-7 + - run: cargo test --features=reopen-03 + - run: cargo test --features=reopen-1 + - run: cargo test --features=meta-logging-in-format + - run: cargo test --all-features - run: cargo run --example cmd-program - run: cargo run --example cmd-program -- --verbose - run: cargo run --example colored --features colored @@ -90,26 +50,25 @@ jobs: env: RUSTDOCFLAGS: -D warnings linux: - name: Linux-only Examples + name: Linux Examples runs-on: ubuntu-latest strategy: matrix: rust: - stable - beta + toolchain: + - stable + - 1.70.0 steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: ${{ matrix.rust }} - override: true + - uses: actions/checkout@v4 + - run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }} - run: cargo run --example syslog3 --features syslog-3 - run: cargo run --example syslog4 --features syslog-4 - run: cargo run --example syslog --features syslog-6 - run: cargo run --example syslog7 --features syslog-7 msrv: - name: MSRV Compatability - fern + name: MSRV Compat runs-on: ${{ matrix.os }} strategy: matrix: @@ -117,88 +76,14 @@ jobs: - ubuntu-latest - windows-latest steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - # when updating this, also update rust-version in Cargo.toml - toolchain: 1.60.0 - override: true + - uses: actions/checkout@v4 + - run: rustup update 1.60.0 && rustup default 1.60.0 - run: cargo build - msrv2: - name: MSRV Compatability - fern/date-based - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: - - ubuntu-latest - - windows-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: 1.63.0 - override: true - - run: cargo build --features date-based - - run: cargo build --features reopen-1,reopen-03,meta-logging-in-format,syslog-3 - msrv_syslog_4: - name: MSRV Compatability - fern/syslog-4 - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: - - ubuntu-latest - - windows-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: 1.65.0 - override: true - - run: cargo build --features syslog-4 - msrv_syslog_6: - name: MSRV Compatability - fern/syslog-6 - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: - - ubuntu-latest - - windows-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: 1.67.1 - override: true - - run: cargo build --features syslog-6 - msrv_syslog_7: - name: MSRV Compatability - fern/syslog-7 - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: - - ubuntu-latest - - windows-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: 1.67.1 - override: true - - run: cargo build --features syslog-7 - fmt_and_clippy: + optional_lints: name: Optional Lints runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true + - uses: actions/checkout@v4 + - run: rustup update stable && rustup default stable - run: cargo fmt --check - run: cargo clippy --all-features --all-targets -- -D warnings diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 16e0eeb..f3897a4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,18 +1,26 @@ -### Contributing +# Contributing -#### Getting started (section in README) -Contributions are welcome! +## Overview (mirrored in README) -The easiest way for you to contribute right now is to use `fern` in your application, and see where it's lacking. The current library should have a solid base, but not many log adapters or niche features. +There's one thing I need right now, more than anything else: input on what fern does well, and what it should keep +doing well. See [Project Direction](#project-direction). -If you have a use case `fern` does not cover, filing an issue will be immensely useful to me, to anyone wanting to contribute to the project, and (hopefully) to you once the feature is implemented! +Besides that, I'm open to PRs! I'll probably review promptly, and I'm always open to being nudged if I don't. -If you've just filed an issue, or you want to approach one of our [existing ones](https://github.com/daboross/fern/issues), mentoring is available! Tag me with @daboross on an issue, or send me an email at daboross @ daboross.net, and I'll be available to help. +For small PRs, I'll mark anything I need changed in a review, and work with you on that. -As a note, all contributions are expected to follow [the Rust Code of Conduct](https://www.rust-lang.org/en-US/conduct.html). +For larger PRs, I reserve the right to pull in your commits as they are, then fix things I want to be different myself. +In a workplace, I'd try to never do this - but this is a hobby project for me, and I'd rather be overly particular about +fern's implementation than be reasonable. -#### `fern` project structure +This is a change from my previous policy. + +## Code of Conduct. + +All interactions are expected to follow [the Rust Code of Conduct](https://www.rust-lang.org/en-US/conduct.html). + +## `fern` project structure Fern attempts to be an idiomatic rust library and to maintain a sane structure. All source code is located in `src/`, and tests are in `tests/`. @@ -24,7 +32,7 @@ The source is split into four modules: Hopefully these modules are fairly separated, and it's clear when you'll need to work on multiple sections. Adding a new log implementation, for instance, will need to touch `builders.rs` for configuration, and `log_impl.rs` for the implementation - both pieces of code will connect via `builders::Dispatch::into_dispatch`, but besides that, things should be fairly separate. -#### Pull requests +## Pull requests Pull requests are _the_ way to change code using git. If you aren't familiar with them in general, GitHub has some [excellent documentation](https://help.github.com/articles/about-pull-requests/). @@ -32,32 +40,21 @@ There aren't many hard guidelines in this repository on how specifically to form - Please include a descriptive title for your pull request, and elaborate on what's changed in the description. - Feel free to open a PR before the feature is completely ready, and commit directly to the PR branch. - - This is also great for review of PRs before merging - - All commits will be squashed together on merge, so don't worry about force pushing yourself. - Please include at least a short description in each commit, and more of one in the "main" feature commit. Doesn't have to be much, but someone reading the history should easily tell what's different now from before. -- If you have `rustfmt-nightly` installed, using it is recommended. I can also format the code after merging the code, - but formatting it consistently will make reviewing nicer. - -### Testing +- Use `cargo fmt` to format your code. +## Testing -Building fern is as easy as is expected, `cargo build`. - -As of fern 0.5, testing can also easily be done with `cargo test`. - -To run and test the example programs, use: +To run build everything and run all tests, use: ```sh -cargo run --example cmd-program # test less logging -cargo run --example cmd-program -- --verbose # test more logging -cargo run --example colored --features=colored # test colored log levels +cargo build --all-features --all-targets +cargo test --all-features ``` -Feel free to add tests and examples demonstrating new features as you see fit. Pull requests which solely add new/interesting example programs are also welcome. - -### Mentoring +## Mentoring -With all that said, contributing to a library, especially if new to rust, can be daunting. +Contributing to a project can be daunting. -Feel free to email me at daboross @ daboross.net with any questions! +Email me at daboross @ daboross.net with any questions! diff --git a/Cargo.toml b/Cargo.toml index 503d26d..730d343 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ name = "fern" version = "0.7.1" authors = ["David Ross "] description = "Simple, efficient logging" -edition = "2018" +edition = "2021" # when updating this, also update toolchain in .github/workflows/rust.yml rust-version = "1.60" diff --git a/README.md b/README.md index c759779..d023de1 100644 --- a/README.md +++ b/README.md @@ -2,30 +2,17 @@ fern ==== [![crates.io version badge][cratesio-badge]][fern-crate] [![Build Status][test-status-badge]][test-status-link] -[![Average time to resolve an issue][issue-resolution-badge]][isitmaintained-link] -Simple, efficient logging for [Rust]. - ---- - -## fern 0.4.4, 0.5.\*, 0.6.\* security warning - `colored` feature + global allocator - -One of our downstream dependencies, [atty](https://docs.rs/atty/), through -[colored](https://docs.rs/colored/), has an unsoundness issue: -. - -This shows up in one situation: if you're using `colored` 0.1.0 (the crate, or our -feature), and a custom global allocator. - -Upgrade to `fern` 0.7.0, and `colored` 0.2.0 if you depend on it directly, to fix this issue. +- [documentation][fern-docs] +- [crates.io page][fern-crate] +- [example program][fern-example] ---- +Simple, efficient logging for [Rust]. -Logging configuration is recursively branched, like a fern: formatting, filters, and output can be applied recursively to match increasingly specific kinds of logging. Fern provides a builder-based configuration backing for rust's standard [log] crate. +Logging configuration is recursively branched: formatting, filters, and output can be applied at each +`fern::Dispatch`, applying to increasingly specific kinds of logging. ```rust -//! With fern, we can: - // Configure logger at runtime fern::Dispatch::new() // Perform allocation-free log formatting @@ -49,30 +36,41 @@ fern::Dispatch::new() .apply()?; // and log using log crate macros! -info!("hello, world!"); +log::info!("hello, world!"); ``` Examples of all features at the [api docs][fern-docs]. See fern in use with this [example command line program][fern-example]. ---- +## Project Direction -- [documentation][fern-docs] -- [crates.io page][fern-crate] -- [example program][fern-example] +I've posted a GitHub Discussion talking about the future of fern: https://github.com/daboross/fern/discussions/147 + +If you've ever used fern, or you do today, I'd love input! -### Project Status +## fern 0.4.4, 0.5.\*, 0.6.\* security warning - `colored` crate + custom global allocator -The fern project is primarily maintained by myself, @daboross on GitHub. It's a hobby project, but one I aim to keep at a high quality. +One of our downstream dependencies, [atty](https://docs.rs/atty/), through +[colored](https://docs.rs/colored/), has an unsoundness issue: +. + +This shows up in one situation: if you're using `colored` 0.1.0 and a custom global allocator. + +Upgrade to `fern` 0.7.0 to fix. ### Contributing -As this is a hobby project, contributions are very welcome! +There's one thing I need right now, more than anything else: input on what fern does well, and what it should keep +doing well. See [Project Direction](#project-direction). + +Besides that, I'm open to PRs! I'll probably review promptly, and I'm always open to being nudged if I don't. -The easiest way for you to contribute right now is to use fern in your application, and see where it's lacking. The current library has a solid base, but it lacks features, and I may not anticipate your use cases. +For small PRs, I'll mark anything I need changed in a review, and work with you on that. -If you have a use case fern does not cover, please file an issue. This is immensely useful to me, to anyone wanting to contribute to the project, and to you as well if the feature is implemented. +For larger PRs, I reserve the right to pull in your commits as they are, then fix things I want to be different myself. +In a workplace, I'd try to never do this - but this is a hobby project for me, and I'd rather be overly particular about +fern's implementation than be reasonable. -If you're interested in helping fix an [existing issue](https://github.com/daboross/fern/issues), or an issue you just filed, help is appreciated. +This is a change from my previous policy. See [CONTRIBUTING](./CONTRIBUTING.md) for technical information on contributing. diff --git a/examples/meta-logging.rs b/examples/meta-logging.rs index cdf0fc9..4f17fc1 100644 --- a/examples/meta-logging.rs +++ b/examples/meta-logging.rs @@ -21,7 +21,7 @@ fn main() { // Display implementation which performs logging: struct Thing<'a>(&'a str); - impl<'a> fmt::Display for Thing<'a> { + impl fmt::Display for Thing<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { debug!("formatting Thing wrapping ({})", self.0); f.write_str(self.0) diff --git a/src/builders.rs b/src/builders.rs index fd7a075..5ea791b 100644 --- a/src/builders.rs +++ b/src/builders.rs @@ -607,7 +607,7 @@ impl Dispatch { (real_min, dispatch) } - /// Builds this logger into a `Box` and calculates the minimum + /// Builds this logger into a `Box` and calculates the minimum /// log level needed to have any effect. /// /// While this method is exposed publicly, [`Dispatch::apply`] is typically @@ -1051,7 +1051,7 @@ impl Output { /// Returns a logger using arbitrary write object and custom separator. /// - /// If the default separator of `\n` is acceptable, an `Box` + /// If the default separator of `\n` is acceptable, an `Box` /// instance can be passed into [`Dispatch::chain`] directly. /// /// ```no_run @@ -1061,7 +1061,7 @@ impl Output { /// /// fern::Dispatch::new() /// // as long as we explicitly cast into a type-erased Box - /// .chain(Box::new(writer) as Box) + /// .chain(Box::new(writer) as Box) /// # .into_log(); /// # Ok(()) /// # } @@ -1375,7 +1375,7 @@ impl Default for Dispatch { impl fmt::Debug for Dispatch { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { struct LevelsDebug<'a>(&'a [(Cow<'static, str>, log::LevelFilter)]); - impl<'a> fmt::Debug for LevelsDebug<'a> { + impl fmt::Debug for LevelsDebug<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_map() .entries(self.0.iter().map(|t| (t.0.as_ref(), t.1))) @@ -1383,7 +1383,7 @@ impl fmt::Debug for Dispatch { } } struct FiltersDebug<'a>(&'a [Box]); - impl<'a> fmt::Debug for FiltersDebug<'a> { + impl fmt::Debug for FiltersDebug<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_list() .entries(self.0.iter().map(|_| "")) diff --git a/src/lib.rs b/src/lib.rs index ffced19..917fafd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -144,7 +144,7 @@ //! [`Dispatch::chain`] accepts [`Stdout`], [`Stderr`], [`File`] and other //! [`Dispatch`] instances. //! -//! ``` +//! ```no_run //! # fern::Dispatch::new() //! .chain(fern::log_file("output.log")?) //! # ; >>::Ok(()) diff --git a/src/log_impl.rs b/src/log_impl.rs index 9b0d843..edc1e1b 100644 --- a/src/log_impl.rs +++ b/src/log_impl.rs @@ -509,7 +509,7 @@ impl Dispatch { } } -impl<'a> FormatCallback<'a> { +impl FormatCallback<'_> { /// Complete the formatting call that this FormatCallback was created for. /// /// This will call the rest of the logging chain using the given formatted diff --git a/tests/meta_logging.rs b/tests/meta_logging.rs index b84c240..49d2bae 100644 --- a/tests/meta_logging.rs +++ b/tests/meta_logging.rs @@ -19,7 +19,7 @@ struct VerboseDisplayThing<'a> { msg: &'a str, } -impl<'a> fmt::Display for VerboseDisplayThing<'a> { +impl fmt::Display for VerboseDisplayThing<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { manual_log( self.log_copy,