Skip to content

A light-weight customizable logger implementation for rust

License

NaturalIO/captains-log

Repository files navigation

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 KeyFilter 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"

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

About

A light-weight customizable logger implementation for rust

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages