Crate logforth

Crate logforth 

Source
Expand description

Logforth is a flexible logging framework for Rust applications, providing easy log dispatching and configuration.

§Overview

Logforth allows you to set up multiple log dispatches with different filters and appenders. You can configure global log levels, use built-in appenders for stdout, stderr, files, or create custom appenders.

It provides out-of-the-box integrations with the log crate:

cargo add log
cargo add logforth -F starter-log

§Examples

Simple setup with default stdout appender:

logforth::starter_log::stdout().apply();

log::info!("This is an info message.");

Advanced setup with custom filters and multiple appenders:

use logforth::append;
use logforth::record::LevelFilter;

logforth::starter_log::builder()
    .dispatch(|d| {
        d.filter(LevelFilter::Error)
            .append(append::Stderr::default())
    })
    .dispatch(|d| {
        d.filter(LevelFilter::Info)
            .append(append::Stdout::default())
    })
    .apply();

log::error!("Error message.");
log::info!("Info message.");

Modules§

append
Dispatch log records to various targets.
bridge
Bridge logforth with other logging frameworks.
core
Core components of the logforth logging framework.
diagnostic
Mapped Diagnostic Context (MDC).
filter
Filters for log records.
kv
Key-value pairs in a log record or a diagnostic context.
layout
Layouts for formatting log records.
record
Log record and metadata.
starter_logbridge-log
Starter configurations for quickly setting up logforth with the log crate
trap
Traps for processing errors.

Structs§

Error
The error struct of logforth.

Traits§

Append
An appender that can process log records.
Diagnostic
A Mapped Diagnostic Context (MDC) that provides diagnostic key-values.
Filter
A filter that can be applied to log records.
Layout
A layout for formatting log records.