Skip to content
This repository has been archived by the owner on Jun 4, 2023. It is now read-only.
/ slog-kickstarter Public archive

Builder to setup slog easily

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

elmarx/slog-kickstarter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust build crates.io badge docs.rs badge

Slog Kickstarter 🚀

Builder to setup slog easily.

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.

Features

  • switch between JSON-logging and (compacted) terminal output via environment-variable (RUST_LOG_JSON=1)
  • per-module debug-level (via with_debug_log_for()) — i.e. enable debugging for your own modules, but ignore debug-logs from 3rd-party crates
  • logging configuration via RUST_LOG=…, as known from env_logger (implemented by slog-envlogger), all preconfigured
  • log support by default (unless explicitly disabled)

Usage

See 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"));
}

About

Builder to setup slog easily

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Languages