#init #arguments #tracing #stderr #info

ts_init

A simple template for Rust project with tracing

3 releases

new 0.1.2 Apr 27, 2025
0.1.1 Oct 12, 2024
0.1.0 Jul 5, 2024

#19 in #stderr

Download history

138 downloads per month

MIT license

12KB
171 lines

Initializes logging based on the specified environment and output configurations.


lib.rs:

Initializes logging based on the specified environment and output configurations.

This function configures the global logging behavior according to the specified outputs and the environment string provided. It supports conditional logging to stderr, files, or journald based on the inputs.

Arguments

  • outputs - A vector of Option<String> where each element represents an optional output destination. Supported values are file paths and "journald".
  • env - A string slice that represents the logging environment. It can be a simple level string like "debug" or a detailed filter like "my_crate=info,my_crate::module=debug".

Examples

// Output info log of current crate to stderr
ts_init::init(ts_init::env_filter_directive!("info"));

Dependencies

~7.5MB
~119K SLoC