Crates.io | logforth |
lib.rs | logforth |
version | 0.16.0 |
source | src |
created_at | 2024-08-01 03:44:24.993417 |
updated_at | 2024-10-30 14:52:21.540585 |
description | A versatile and extensible logging implementation. |
homepage | https://github.com/fast/logforth |
repository | https://github.com/fast/logforth |
max_upload_size | |
id | 1321572 |
size | 174,831 |
Logforth is a flexible and easy-to-use logging framework for Rust applications. It allows you to configure multiple dispatches, filters, and appenders to customize your logging setup according to your needs.
Add log
and logforth
to your Cargo.toml
:
cargo add log
cargo add logforth
Set up a basic logger that outputs to stdout:
fn main() {
logforth::stdout().apply();
log::info!("This is an info message.");
log::debug!("This debug message will not be printed by default.");
}
Configure multiple dispatches with different filters and appenders:
use logforth::append;
use log::LevelFilter;
fn main() {
logforth::builder()
.dispatch(|d| d
.filter(LevelFilter::Error)
.append(append::Stderr::default()))
.dispatch(|d| d
.filter(LevelFilter::Info)
.append(append::Stdout::default()))
.apply();
log::error!("This error will be logged to stderr.");
log::info!("This info will be logged to stdout.");
log::debug!("This debug message will not be logged.");
}
Read more demos under the examples directory.
Read the online documents at https://docs.rs/logforth.
This crate is built against the latest stable release, and its minimum supported rustc version is 1.75.0.
The policy is that the minimum Rust version required to use this crate can be increased in minor version updates. For example, if Logforth 1.0 requires Rust 1.20.0, then Logforth 1.0.z for all values of z will also require Rust 1.20.0 or newer. However, Logforth 1.y for y > 0 may require a newer minimum version of Rust.
After one year of practicing the interfaces, if there are no further blockers, I'll release a 1.0 version. So consequently, it can be as early as 2025-08.
This project is licensed under Apache License, Version 2.0.
The name Logforth
comes from an antonym to the Logback
project.