Crate logs[][src]

Expand description

Example

use logs::{debug, error, info, trace, warn};

debug!("This is a debug log");
trace!("This is a trace log");
info!("This is a info log");
warn!("This is a warn log");
error!("This is a error log");

Config

use logs::{LogConfig, debug, error};

let mut config = LogConfig::disable_all();

// Disable debug! output
config.debug(false);

// Allow error! output
config.error(true);

// The output of `trace!` is only displayed in debug mode
#[cfg(debug_assertions)]
config.trace(true);

// Enable color display
config.color(true);

// Change datetime format: [Fri Nov 27 15:56:08 2020]
config.date_format("%c").unwrap();
      
config.apply();

debug!("This is a debug log");
error!("This is a error log");

env

This can be configured by reading the LOG environment variable, which disables all output by default

# Enable all output
# Disable debug output
# ...
export LOG='all,!debug,info,!error'
use logs::LogConfig;

LogConfig::from_env().unwrap_or_default().apply();

Macros

debug
error
info
trace
warn

Structs

LogConfig

Configuration Log

Enums

LogError

Log Error