#logging #log #logger

bin+lib my-env-logger-style

pretty, opinionated style for env_logger

2 releases

0.1.1 Oct 27, 2023
0.1.0 May 6, 2023

#431 in Debugging

Download history 41/week @ 2023-11-08 49/week @ 2023-11-15 34/week @ 2023-11-22 81/week @ 2023-11-29 48/week @ 2023-12-06 22/week @ 2023-12-13 20/week @ 2023-12-20 16/week @ 2023-12-27 13/week @ 2024-01-03 24/week @ 2024-01-10 64/week @ 2024-01-17 20/week @ 2024-01-24 13/week @ 2024-01-31 24/week @ 2024-02-07 106/week @ 2024-02-14 73/week @ 2024-02-21

222 downloads per month
Used in 2 crates

MIT/Apache

14KB
159 lines

my-env-logger-style License: MIT OR Apache-2.0 my-env-logger-style on crates.io my-env-logger-style on docs.rs Source Code Repository

A pretty, opinionated style for env_logger inspirated by pretty-env-logger.

It is not a goal of this crate to create a feature rich wrapper around env_logger. Instead it does provide a formater, which can be applied to the env_logger::Builder. Additional an optional function to create and register a zero config logger is provided.

Timestamp, emojis and modules can be disable separately.

Preview

image

with timestamps:

image

Usage

Quickstart
my_env_logger_style::just_log();
info!("Hello, world!");

This creates the default env_logger from environment variables and register it as logger.

Advance

You can also create an env_logger::Builder and apply the style definded at this crate, by using the format() function.

use log::info;
use my_env_logger_style::format;

env_logger::Builder::new()
	.parse_default_env()
	.format(format)
	.init();
info!("Hello, world!");

Feature-flags

time (default)

Enable RFC3339 timestamps

custom-arg-formatter

Allow using a custom formater to format the args (the actual message) of the log record. As example this can be used to avoid logging private userdata.

Dependencies

~0.1–8.5MB
~54K SLoC