f_log
F Log is a simple, fast, and efficient Rust logger
Features
- Logging with background flush
- Configurable logger parameters for latency and throughput
- Convenient logging macros (
trace!,debug!,info!,warn!,error!) - Uses
compact_strfor efficient string storage - Customizable logger configuration through
LoggerConfig
Getting Started
Add f_log to your Cargo.toml dependencies:
[]
= "0.1"
Basic Usage
Initialize the logger with your preferred configuration and use the logging macros as shown below:
use Instant;
use ;
Logger Configuration
You can configure f_log using the LoggerConfig struct:
LoggerConfig::default()– Balanced defaultsLoggerConfig::low_latency()– Prioritizes low latency with smaller buffers and frequent flushesLoggerConfig::high_throughput()– Prioritizes throughput with larger buffers and batching
Example:
use ;
Logging Scope: Global vs Local
f_log supports two logging scopes:
- Global logger — Shared across all threads and modules
- Local logger — Thread-local logger, independent for each thread
Choose based on your use case. Here are examples using threads.
Example: Global Logger with Threads
use thread;
use ;
Example: Local Logger with Threads
use thread;
use ;
License
Licensed under MIT OR Apache-2.0