captains-log

Crates.iocaptains-log
lib.rscaptains-log
version0.13.1
created_at2025-06-08 18:38:58.192964+00
updated_at2025-09-15 02:29:18.447817+00
descriptionA minimalist customizable logger for rust, based on the `log` crate, but also adapted to `tracing`, for production and testing scenario.
homepage
repositoryhttps://github.com/NaturalIO/captains-log
max_upload_size
id1705157
size216,635
Adam Ning (frostyplanet)

documentation

https://docs.rs/captains-log

README

captains-log

A minimalist, customizable, easy to use logger for rust, based on the log crate, also adapted to tracing, for production and testing scenario.

crates.io: crates.io docs.rs: docs.rs

Features

  • Allow customize log format and time format. Refer to LogFormat

  • Dynamic reconfigurable.

  • Support subscribing span and event log from tracing (feature tracing) with consistent format:

    • global default subscriber mode

    • layer mode

    • scoped mode

  • Multiple types of sink stacking, each with its own log level.

    • LogConsole: Console output to stdout/stderr.

    • LogRawFile: Support atomic appending from multi-process on linux (with ext4, xfs)

    • LogBufFile: Write to log file with merged I/O and delay flush, and optional self-rotation.

    • Syslog: (feature syslog)

      Write to local or remote syslog server, with timeout and auto reconnect.

    • LogRingFile: (feature ringfile)

      For deadlock / race condition debugging, collect log to ring buffer in memory, flush on panic or by signal.

  • Log panic message by default.

  • Provide additional macros. For example: log_assert!(), logger_assert!() ...

  • Supports signal listening for log-rotate. Refer to Builder::signal()

  • Provides many preset recipes in recipe module for convenience.

  • Supports configured by environment

  • Fine-grain module-level control and API-level log handling.

    Provides LogFilter and LogFilterKV to filter specified logs on-the-fly. Refer to doc

  • For test suits usage:

  • Provides a parser to work on your log files.

Usage

Cargo.toml

[dependencies]
log = { version = "0.4", features = ["std", "kv_unstable"] }
captains_log = "0.13"

lib.rs or main.rs:


// By default, reexport the macros from log crate
#[macro_use]
extern crate captains_log;

Features flags

  • syslog: Enable [Syslog] sink

  • ringfile: Enable [LogRingFile] sink

  • tracing: Receive log from tracing

...

See detail usage on docs.rs

Commit count: 167

cargo fmt