2 releases

0.1.1 Oct 12, 2024
0.1.0 Jul 5, 2024

#358 in Configuration

Download history 115/week @ 2024-07-02 9/week @ 2024-07-09 18/week @ 2024-07-30 5/week @ 2024-09-10 2/week @ 2024-09-17 24/week @ 2024-09-24 7/week @ 2024-10-01 161/week @ 2024-10-08 16/week @ 2024-10-15

209 downloads per month

MIT license

6KB
59 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

init_logging(vec![None, Some("log.log".to_string())], "debug");
init_logging(vec![None, Some("journald".to_string())], "debug");
init_logging(vec![Some("journald".to_string())], "debug");

Panics

This function panics if the outputs vector has more than two elements or if the specified logging configuration is invalid.

Errors

This function sets the global default logger and may return an error if logging initialization fails due to system-level constraints or invalid configurations.

Dependencies

~6.5MB
~100K SLoC