#log-level #logging #configuration #log-file #config-file #module

bin+lib mod_logger

A consumer for the log crate that allows module-wise configuration

10 releases

0.8.4 Jan 20, 2024
0.8.3 Jan 1, 2024
0.8.1 Apr 16, 2022
0.8.0 Aug 20, 2020
0.6.1 May 28, 2020

#460 in Debugging

Download history 1/week @ 2024-01-21 107/week @ 2024-02-04 220/week @ 2024-02-11 146/week @ 2024-02-18 156/week @ 2024-02-25 70/week @ 2024-03-03 57/week @ 2024-03-10 3/week @ 2024-03-17 52/week @ 2024-03-31 21/week @ 2024-04-07 77/week @ 2024-04-14 60/week @ 2024-04-21 181/week @ 2024-04-28 54/week @ 2024-05-05

374 downloads per month

MIT/Apache

45KB
1K SLoC

ModuleLogger

A logging provider for the rust log crate that can be dynamically configured on a module basis.


lib.rs:

A consumer for the log crate

The crate implements a logger that allows module-wise configuration of logging through configuration files or an API.

Features

  • Log output can be written to stdout, stderr, to file or to a memory buffer.
  • Log output can be colored.
  • Features can be set using a configuration file or the API

The configuration file can be enabled by setting the environment variable LOG_CONFIG to the path of the file. The configuration is specified in YAML format and allows to set the following values. All values are optional.

  • default_level: The default log level, one of trace, debug, info, warn, error, defaults to info
  • mod_level: A list of module name and log level pairs
  • log_dest: One of stdout, stderr, stream, buffer, streamstdout, streamstderr, bufferstdout, bufferstderr.
  • log_stream: The log file name for stream variants of log_dest
  • color: one of true or false
  • brief_info: one of true or false

Sample:

log_level: warn
log_dest: streamstderr
log_stream: debug.log
color: true
brief_info: true
mod_level:
  'test_mod': debug
  'test_mod::test_test': trace

Dependencies

~3–13MB
~128K SLoC