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.
Structs§
- Dispatch
Builder - A builder for configuring a log dispatch, including filters and appenders.
- Logger
- A logger facade that dispatches log records to one or more dispatcher.
- Logger
Builder - A builder for configuring log dispatching and setting up the global logger.
Functions§
- builder
- Creates a new empty
LoggerBuilder
instance for configuring log dispatching. - stderr
- Creates a
LoggerBuilder
with a defaultappend::Stderr
appender and anenv_filter
respectingRUST_LOG
. - stdout
- Creates a
LoggerBuilder
with a defaultappend::Stdout
appender and anenv_filter
respectingRUST_LOG
.
Type Aliases§
- Drop
Guard - An RAII guard that can be used to ensure that a resource is held until it goes out of scope.