Crate traccia

Crate traccia 

Source
Expand description

A lightweight, flexible logging framework for Rust applications.

This crate provides a configurable logging system that supports multiple output targets, customizable formatting, and different log levels. It can be used in both synchronous (blocking) and asynchronous contexts.

§Features

  • Multiple log levels (Debug, Info, Warning, Error)
  • Multiple output targets (Console, File)
  • Customizable log formatting
  • Async and blocking implementations

§Example

use logger::{init, LogLevel};

// Initialize with Info level
init(LogLevel::Info);

// Log messages
info!("Application started");
debug!("This won't be displayed with Info level");
error!("Something went wrong: {}", error);

Macros§

debug
Logs a message at the DEBUG level.
error
Logs a message at the ERROR level.
fatal
Logs a message at the FATAL level.
info
Logs a message at the INFO level.
log
Macro for logging messages at a specific level.
trace
Logs a message at the TRACE level.
warn
Logs a message at the WARN level.

Structs§

Config
Configuration for initializing a logger.
Console
Standard console output target.
DefaultFormatter
Default log message formatter.
DefaultLogger
File
File output target.
Record
Represents a single log record with all relevant metadata.

Enums§

Color
Terminal colors for text output.
Error
FileMode
File open mode for writing log messages.
Hook
Represents a hook that can be set to trigger at specific points in the logging process.
LogLevel
Logging severity levels in ascending order of importance.
Output
Output destination for console log messages.
TargetId
Represents the id of the target where the log message is written. This can be a console output, file path, or a custom string identifier. Useful for identifying the target in hooks / filters.

Traits§

Colorize
Trait for applying colors to strings.
Formatter
Defines a log message formatter.
Logger
Core trait that defines the logging behavior.
Style
Target
Defines an output destination for log messages.

Functions§

init
Initializes the global logger with the specified minimum log level.
init_default
Initializes the global logger with default settings.
init_with_config
Initializes the global logger with a custom configuration.
logger
Retrieves the global logger instance.
parse_level_from_env
Checks the RUST_LOG env variable and tries to parse its value
set_hook
Sets a hook to be called at the specified point in the logging process.