Expand description
§verbosio
A lightweight, macro-based logging utility for CLI tools and scripts. Designed for ergonomics, speed, and optional colored output — with minimal dependencies.
§Features
- Global verbosity level (via
set_verbosity!,get_verbosity!,verbose_env!) - Print messages conditionally based on verbosity (
verbose!,vinfo!,vwarn!,verror!) - Distinct log levels:
INFO,WARN,ERROR - Optional ANSI-colored output via the
colorfeature
§Dependencies
once_cell: For global static verbosity state (always included)colored: Optional, behind thecolorfeature flag
§Example
use verbosio::*;
set_verbosity!(2);
verbose!(1, "Hello World!"); // printed
vinfo!("App started."); // [INFO] App started.
vwarn!(3, "This won't show."); // not printed
verror!("Something went wrong"); // [ERROR] Something went wrong§Environment Support
You can also set verbosity based on the VERBOSE environment variable:
use verbosio::verbose_env;
unsafe {std::env::set_var("VERBOSE", "2");}
verbose_env!(); // Sets verbosity to 2Re-exports§
Modules§
Macros§
- get_
verbosity - Retrieves the current global verbosity level.
- set_
verbosity - Sets the global verbosity level.
- verbose
- Prints a message to stdout if the verbosity is high enough.
- verbose_
env - Sets verbosity level based on the
VERBOSEenvironment variable. - verror
- Prints an
[ERROR]message to stderr if the verbosity is high enough. - vinfo
- Prints an
[INFO]message to stdout if the verbosity is high enough. - vwarn
- Prints a
[WARN]message to stdout if the verbosity is high enough.