#log #logger #std-io #cli #logging #log-level

loggerv

A simple log implementation that logs to stdout and stderr with colors

9 releases (breaking)

Uses old Rust 2015

0.7.2 Aug 16, 2019
0.7.1 Mar 3, 2018
0.7.0 Jan 18, 2018
0.6.0 Nov 26, 2017
0.2.0 Mar 7, 2016

#243 in Command-line interface

Download history 647/week @ 2023-11-27 550/week @ 2023-12-04 709/week @ 2023-12-11 644/week @ 2023-12-18 463/week @ 2023-12-25 1060/week @ 2024-01-01 551/week @ 2024-01-08 698/week @ 2024-01-15 854/week @ 2024-01-22 892/week @ 2024-01-29 854/week @ 2024-02-05 788/week @ 2024-02-12 757/week @ 2024-02-19 636/week @ 2024-02-26 619/week @ 2024-03-04 258/week @ 2024-03-11

2,377 downloads per month
Used in 21 crates (20 directly)

MIT license

38KB
375 lines

loggerv

build status coverage status crates status

A simple stdout and stderr writing Logger implementation of the log crate, using ansi_term for colors and configured via a log level. Designed for simple Command Line Interfaces (CLIs).

Usage

First, add this to your Cargo.toml:

[dependencies]
log = "0.4"
loggerv = "0.7"

Next, add this to the main.rs or the file containing the main function for your CLI program:

extern crate loggerv;

Getting Started

Clone this repository, then run the following commands to see the log level change:

$ cargo run --example quick
$ cargo run --example quick -- -v
$ cargo run --example quick -- -vv
$ cargo run --example quick -- -vvv

This will run an example that uses the clap argument parser to change the log level at run-time based on the number of -v arguments that are passed to the application. As the occurrence of the -v argument increases, the number of log statements that are displayed should increase.

Next, run the following commands:

$ cargo run --example compile-time-config

This will run an example that changes the output from defaults at compile-time. The following commands will demonstration configuration at run-time:

$ cargo run --example run-time-config
$ cargo run --example run-time-config -- -v
$ cargo run --example run-time-config -- -vv
$ cargo run --example run-time-config -- -vvv
$ cargo run --example run-time-config -- -vvv
$ cargo run --example run-time-config -- -vvv -l
$ cargo run --example run-time-config -- -vvv -l -d
$ cargo run --example run-time-config -- -vvv -l -d --no-module-path
$ cargo run --example run-time-config -- -vvv -l -d --no-module-path --no-color

Similar to the quick example, as the occurrence of the -v argument increases, the number of log statements that are displayed should increase. As the various configuration arguments, i.e. -l, -d, etc. are added, the format of the log statements change. The -h,--help flag can be used to display information about the various flags and their effects on logging and output.

Finally, run the following commands to demonstration build profile configuration:

$ cargo run --example cfg-config
$ cargo run --release --example cfg-config

The number of log statements are displayed based on the build profile, either Debug or Release.

Documentation

License

MIT-Licensed. See LICENSE file for details.

Dependencies

~125–380KB