Crates.io | captains-log |
lib.rs | captains-log |
version | 0.13.1 |
created_at | 2025-06-08 18:38:58.192964+00 |
updated_at | 2025-09-15 02:29:18.447817+00 |
description | A minimalist customizable logger for rust, based on the `log` crate, but also adapted to `tracing`, for production and testing scenario. |
homepage | |
repository | https://github.com/NaturalIO/captains-log |
max_upload_size | |
id | 1705157 |
size | 216,635 |
A minimalist, customizable, easy to use logger for rust, based on the log
crate, also adapted to tracing
,
for production and testing scenario.
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:
Allow dynamic reconfigure logger setting in different test function.
Refer to Unit test example.
Provides an attribute macro #[logfn] to wrap test function.
Refer to Best practice with rstest
Provides a parser
to work on your log files.
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;
syslog: Enable [Syslog] sink
ringfile: Enable [LogRingFile] sink
tracing: Receive log from tracing
...
See detail usage on docs.rs