Crate verbosio

Source
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 color feature

§Dependencies

  • once_cell: For global static verbosity state (always included)
  • colored: Optional, behind the color feature 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 2

Re-exports§

pub use macros::*;
pub use util::*;

Modules§

macros
util

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 VERBOSE environment 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.

Statics§

VERBOSE