fastlogging 0.8.0

A lightning fast logger, written in Rust, for multiple platforms and languages.
Documentation

fastlogging — Documentation

fastlogging is a high-performance, thread-safe structured logging library for Rust. It routes messages through an asynchronous background thread to one or more independent writers (console, file, network client/server, syslog, callback), keeping your hot path free of blocking I/O — each call is a cheap level check followed by a channel send.

Table of Contents

The full guide (quick start, architecture, features, platform notes) lives in doc/README.md.

Quick Start

Add to Cargo.toml:

[dependencies]
fastlogging = "0.8"

One-liner default logger

use fastlogging::{logging_new_default, LoggingError};

fn main() -> Result<(), LoggingError> {
    let mut log = logging_new_default()?;
    log.info("Hello, fastlogging!")?;
    log.shutdown(false)?;
    Ok(())
}

Explicit console logger

use fastlogging::{ConsoleWriterConfig, DEBUG, Logging, LoggingError};

fn main() -> Result<(), LoggingError> {
    let mut log = Logging::new(
        DEBUG,
        "myapp",
        Some(vec![ConsoleWriterConfig::new(DEBUG, true).into()]),
        None,
        None,
    )?;
    log.debug("starting up")?;
    log.info("ready")?;
    log.shutdown(false)?;
    Ok(())
}

Architecture

Log calls never touch I/O on the caller's thread. Each call performs a level check (the hot path), and if it passes, the message is handed to a flume-backed channel. A single LoggingThread running in the background drains that channel and dispatches to each writer's own thread.

@startuml

participant "Your code" as code
participant "server_tx\n(flume channel)" as ch
participant "LoggingThread\n(background)" as lt
participant "ConsoleWriter\n(thread)" as cw
participant "FileWriter\n(thread)" as fw
participant "ClientWriter\n(thread)" as clw
participant "LoggingServer\n(thread)" as ls
participant "CallbackWriter\n(thread)" as cbw
participant "SyslogWriter\n(thread, unix)" as sw

code -> code : level check\n(hot path — single\ninteger compare,\nno lock)
code -> ch : push message
ch -> lt : deliver

lt -> cw : dispatch
lt -> fw : dispatch
lt -> clw : dispatch
lt -> ls : dispatch
lt -> cbw : dispatch
lt -> sw : dispatch

@enduml

Each writer runs in its own background thread and consumes messages from a bounded channel. The level check on the hot path is a single integer comparison with no locking.

Crate Features

Feature Default Description
config_json ✔ Save / load configuration as JSON
config_yaml ✔ Save / load configuration as YAML
config_xml ✔ Save / load configuration as XML

Disable all three to get a dependency-light build:

fastlogging = { version = "0.8", default-features = false }

Platform Notes

  • SyslogWriter / SyslogWriterConfig are available on Unix only (#[cfg(target_family = "unix")]). On Windows the equivalent is eventlog-backed and exposed under the same type names.

Language Bindings

The Rust core is wrapped for other languages in sibling crates/directories:

Binding Layer Repository dir
C raw extern "C" ABI (cbindgen header) cfastlogging
C++ (cxx) type-safe cxx bridge cxxfastlogging
C++ (wrapper) C++17 RAII over the C ABI cppfastlogging
Go cgo wrapper gofastlogging
Python PyO3/maturin pyfastlogging
Java (JNI) JNI bindings jfastlogging-jni
Java (FFM) Foreign Function & Memory API jfastlogging-ffm