#logger

sloggers

This library provides frequently used slog loggers and convenient functions

26 releases (2 stable)

1.0.1 May 11, 2020
0.3.6 Apr 25, 2020
0.3.5 Dec 11, 2019
0.3.4 Sep 8, 2019
0.2.0 Jun 15, 2017

#34 in Debugging

Download history 2025/week @ 2020-04-20 1811/week @ 2020-04-27 1880/week @ 2020-05-04 2546/week @ 2020-05-11 1844/week @ 2020-05-18 2532/week @ 2020-05-25 1843/week @ 2020-06-01 1579/week @ 2020-06-08 1572/week @ 2020-06-15 1536/week @ 2020-06-22 1488/week @ 2020-06-29 1834/week @ 2020-07-06 1367/week @ 2020-07-13 2193/week @ 2020-07-20 2206/week @ 2020-07-27 2508/week @ 2020-08-03

5,622 downloads per month
Used in 27 crates (23 directly)

MIT license

54KB
1K SLoC

sloggers - convenience library for slog

Crates.io: sloggers Documentation Build Status Code Coverage 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

~5MB
~104K SLoC