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 integrates seamlessly with the log
crate.
§Examples
Simple setup with default stdout appender:
logforth::stdout().apply();
log::info!("This is an info message.");
Advanced setup with custom filters and multiple appenders:
use log::LevelFilter;
use logforth::append;
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!("Error message.");
log::info!("Info message.");
Re-exports§
pub extern crate colored;
pub use append::Append;
pub use diagnostic::Diagnostic;
pub use filter::Filter;
pub use layout::Layout;
Modules§
- append
- Dispatch log records to various targets.
- color
colored
- Color utilities.
- diagnostic
- Mapped Diagnostic Context (MDC). A lighter technique consists of uniquely stamping each log request.
- filter
- Filters for log records.
- layout
- Layouts for formatting log records.
- non_
blocking non-blocking
Structs§
- Builder
- A builder for configuring log dispatching and setting up the global logger.
- Dispatch
Builder - A builder for configuring a log dispatch, including filters and appenders.
Functions§
- builder
- Creates a new empty
Builder
instance for configuring log dispatching. - stderr
- Creates a
Builder
with a defaultappend::Stderr
appender and anenv_filter
respectingRUST_LOG
. - stdout
- Creates a
Builder
with a defaultappend::Stdout
appender and anenv_filter
respectingRUST_LOG
.