27 releases (11 stable)

4.1.1 Mar 23, 2022
4.1.0 Oct 22, 2020
4.0.0 Aug 13, 2019
3.0.5 Jul 24, 2019
0.6.0 Jul 19, 2016

#356 in Debugging

Download history 14850/week @ 2023-12-23 28924/week @ 2023-12-30 39310/week @ 2024-01-06 32371/week @ 2024-01-13 38671/week @ 2024-01-20 40699/week @ 2024-01-27 40990/week @ 2024-02-03 41140/week @ 2024-02-10 44261/week @ 2024-02-17 47323/week @ 2024-02-24 51982/week @ 2024-03-02 52139/week @ 2024-03-09 54748/week @ 2024-03-16 51040/week @ 2024-03-23 48291/week @ 2024-03-30 42549/week @ 2024-04-06

205,517 downloads per month
Used in 164 crates (64 directly)

MPL-2.0 OR MIT OR Apache-2.0

17KB
168 lines

Travis CI Build Status slog-stdlog on crates.io slog-rs Gitter Chat Minimum Rust Version 1.38

slog-stdlog - log crate adapter for slog-rs

See slog-stdlog documentation for details.

For more information, help, to report issues etc. see slog-rs.


lib.rs:

log crate adapter for slog-rs

This crate provides two way compatibility with Rust standard log crate.

log -> slog

After calling init() slog-stdlog will take a role of log crate back-end, forwarding all the log logging to slog_scope::logger(). In other words, any log crate logging statement will behave like it was slog logging statement executed with logger returned by slog_scope::logger().

See documentation of slog-scope for more information about logging scopes.

See init documentation for an example.

slog -> log

StdLog is slog::Drain that will pass all Records passing through it to log crate just like they were crated with log crate logging macros in the first place.

slog-scope

Since log does not have any form of context, and does not support Logger slog-stdlog relies on "logging scopes" to establish it.

You must set up logging context for log -> slog via slog_scope::scope or slog_scope::set_global_logger. Setting a global logger upfront via slog_scope::set_global_logger is highly recommended.

Note: Since slog-stdlog v2, unlike previous releases, slog-stdlog uses logging scopes provided by slog-scope crate instead of it's own.

Refer to slog-scope crate documentation for more information.

Warning

Be careful when using both methods at the same time, as a loop can be easily created: log -> slog -> log -> ...

Compile-time log level filtering

For filtering debug! and other log statements at compile-time, configure the features on the log crate in your Cargo.toml:

log = { version = "*", features = ["max_level_trace", "release_max_level_warn"] }

Dependencies

~455KB