diff --git a/.github/screenshot-level-symbols.png b/.github/screenshot-level-symbols.png new file mode 100644 index 0000000..c8b3c76 Binary files /dev/null and b/.github/screenshot-level-symbols.png differ diff --git a/README.md b/README.md index ba2d4af..e4e8011 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,10 @@ If you want to only show some levels, you can add the -f to filter by level or m Will only show warning and error from the log. +If you pass the flag "--level-symbols" or set the environement variable `SNAZY_LEVEL_SYMBOLS`, snazy will show some pretty emojis rather than plain log level label : + +![snazy level symbols](.github/screenshot-level-symbols.png) + You can customize the time printed with the `-t` option which respect the [`strftime`](https://man7.org/linux/man-pages/man3/strftime.3.html) format strings. diff --git a/src/main.rs b/src/main.rs index 7edb99b..6d9d28a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -55,10 +55,17 @@ fn construct_config(matches: clap::ArgMatches) -> Config { std::process::exit(1); } } + let mut level_symbols = false; + // if the env SNAZY_LEVEL_SYMBOLS is set, we use it to set the level symbols + if let Ok(level_symbols_env) = env::var("SNAZY_LEVEL_SYMBOLS") { + level_symbols = level_symbols_env.parse::().unwrap(); + } + if matches.is_present("level-symbols") { + level_symbols = true; + } Config { kail_no_prefix: matches.is_present("kail-no-prefix"), - level_symbols: matches.is_present("level-symbols"), filter_levels: matches .values_of("filter-levels") .map(|v| v.map(String::from).collect()) @@ -66,6 +73,7 @@ fn construct_config(matches: clap::ArgMatches) -> Config { time_format: matches.value_of("time_format").unwrap().to_string(), regexp_colours, colored_output, + level_symbols, // split json keys by '=' and store in a key, value hashmap json_keys: matches .values_of("json-keys")