39 releases

0.7.0 Oct 21, 2024
0.6.2 Mar 23, 2023
0.6.1 Apr 15, 2022
0.6.0 Mar 9, 2020
0.1.3 Dec 28, 2014

#17 in Debugging

Download history 85043/week @ 2024-07-16 90839/week @ 2024-07-23 91108/week @ 2024-07-30 99860/week @ 2024-08-06 95718/week @ 2024-08-13 103394/week @ 2024-08-20 106072/week @ 2024-08-27 108663/week @ 2024-09-03 98855/week @ 2024-09-10 95241/week @ 2024-09-17 104879/week @ 2024-09-24 111977/week @ 2024-10-01 84751/week @ 2024-10-08 111779/week @ 2024-10-15 96665/week @ 2024-10-22 87259/week @ 2024-10-29

395,391 downloads per month
Used in 525 crates (376 directly)

MIT license

305KB
2K SLoC

fern

crates.io version badge Build Status Average time to resolve an issue

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, through colored, has an unsoundness issue: https://rustsec.org/advisories/RUSTSEC-2021-0145.html.

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.


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.

//! With fern, we can:

// Configure logger at runtime
fern::Dispatch::new()
    // Perform allocation-free log formatting
    .format(|out, message, record| {
        out.finish(format_args!(
            "[{} {} {}] {}",
            humantime::format_rfc3339(std::time::SystemTime::now()),
            record.level(),
            record.target(),
            message
        ))
    })
    // Add blanket level filter -
    .level(log::LevelFilter::Debug)
    // - and per-module overrides
    .level_for("hyper", log::LevelFilter::Info)
    // Output to stdout, files, and other Dispatch configurations
    .chain(std::io::stdout())
    .chain(fern::log_file("output.log")?)
    // Apply globally
    .apply()?;

// and log using log crate macros!
info!("hello, world!");

Examples of all features at the api docs. See fern in use with this example command line program.


Project Status

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.

Contributing

As this is a hobby project, contributions are very welcome!

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.

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.

If you're interested in helping fix an existing issue, or an issue you just filed, help is appreciated.

See CONTRIBUTING for technical information on contributing.

Dependencies

~0–8.5MB
~69K SLoC