Crates.io | slog-kickstarter |
lib.rs | slog-kickstarter |
version | 0.2.0 |
source | src |
created_at | 2020-07-06 17:45:21.113144 |
updated_at | 2020-10-02 12:23:16.429997 |
description | builder to easily setup the slog logging ecosystem |
homepage | https://github.com/elmarx/slog-kickstarter |
repository | https://github.com/elmarx/slog-kickstarter |
max_upload_size | |
id | 262033 |
size | 37,690 |
Slog is really great, but to leverage it's features and flexibility, it requires more setup than importing a module and calling a function (to be precise, it requires about 163 lines of code ;)).
Structured logging is great. You should not postpone introducing logging, but integrate it from the beginning, because retrofitting slog could require lots of changes. That's where Slog Kickstarter comes into play.
RUST_LOG_JSON=1
)with_debug_log_for()
) — i.e. enable debugging for your own modules, but ignore debug-logs from 3rd-party cratesRUST_LOG=…
, as known from env_logger (implemented by slog-envlogger), all preconfiguredSee basic.rs for a running example, and full.rs for all features.
use slog::{o, slog_info};
use slog_kickstarter::SlogKickstarter;
fn main() {
// initialize a root logger
let root_logger = SlogKickstarter::new("logging-example").init();
// slog supports string formatting, and additional structured fields
slog_info!(root_logger, "Hello World!"; o!("type" => "example"));
}