Crates.io | logforth |
lib.rs | logforth |
version | 0.19.0 |
source | src |
created_at | 2024-08-01 03:44:24.993417 |
updated_at | 2024-12-07 08:14:16.110407 |
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 | 221,011 |
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.
To release a 1.0 version, it's essential to declare what targets this crate wants to stabilize. Even beyond 1.0, it's helpful to distinguish different portions of this crate to allow unstable modules to make breaking changes to improve their quality, just as how rust-lang's stabilization mechanism works.
Basically, this crate contains:
Generally, there are known usage for Fastrace and OpentelemetryLog, so we can confidently announce their stable version; others are still waiting for feedback.
This project is licensed under Apache License, Version 2.0.
The name Logforth
comes from an antonym to the Logback
project.