#logging #logger #slog #convenience #frequently #function

sloggers

This library provides frequently used slog loggers and convenient functions

33 releases (9 stable)

2.2.0 Jan 27, 2024
2.1.2 Aug 18, 2023
2.1.1 Nov 15, 2021
2.0.1 Jul 3, 2021
0.2.0 Jun 15, 2017

#71 in Debugging

Download history 6210/week @ 2024-07-22 5399/week @ 2024-07-29 4674/week @ 2024-08-05 4782/week @ 2024-08-12 5243/week @ 2024-08-19 6564/week @ 2024-08-26 5054/week @ 2024-09-02 4623/week @ 2024-09-09 4645/week @ 2024-09-16 4655/week @ 2024-09-23 4323/week @ 2024-09-30 5516/week @ 2024-10-07 5456/week @ 2024-10-14 4714/week @ 2024-10-21 5514/week @ 2024-10-28 4373/week @ 2024-11-04

20,282 downloads per month
Used in 32 crates (27 directly)

MIT license

135KB
2.5K SLoC

sloggers - convenience library for slog

Crates.io: sloggers Documentation Actions Status Coverage Status License: MIT Gitter: slog

sloggers provides frequently used slog loggers and convenient functions.

Documentation

Join gitter for help


lib.rs:

This crate provides frequently used slog loggers and convenient functions.

Important note: this crate is optimized for performance rather than for not losing any messages! This may be surprising in some common scenarios, like logging an error message and calling std::process::exit(1). It's recommended to drop the logger(s) before exiting. panic = "abort" may have the same surprising effect, so unwinding is preferrable if you want to avoid losing the messages. See #29 for more information.

Examples

Creates a logger via TerminalLoggerBuilder:

use slog::info;
use sloggers::Build;
use sloggers::terminal::{TerminalLoggerBuilder, Destination};
use sloggers::types::Severity;

let mut builder = TerminalLoggerBuilder::new();
builder.level(Severity::Debug);
builder.destination(Destination::Stderr);

let logger = builder.build().unwrap();
info!(logger, "Hello World!");

Creates a logger from configuration text (TOML):

use slog::info;
use sloggers::{Config, LoggerConfig};

let config: LoggerConfig = serdeconv::from_toml_str(r#"
type = "terminal"
level = "debug"
destination = "stderr"
"#).unwrap();

let logger = config.build_logger().unwrap();
info!(logger, "Hello World!");

Dependencies

~8–17MB
~211K SLoC