Expand description
Simple, Easy LOGger logs to StdErr.
CAUTION: This crate is compatible with
log ^0.4.11
.
This crate provides a simple, minimal and easy to use
implementation of log
crate.
§Example
§Simple Use Case
#[macro_use]
extern crate log;
extern crate selog;
use selog::SELog;
fn main() {
SELog::new().init().unwrap();
error!("Failed something");
// ..
}
§Using clap
Tested on clap 2.33.3
#[macro_use]
extern crate log;
#[macro_use]
extern crate clap;
extern crate selog;
use clap::Arg;
use selog::{Colorize, SELevel, SELog};
use std::str::FromStr;
fn main() {
let m = app_from_crate!()
.args(&[
Arg::from_usage("-v --verbose 'More verbose output.'"),
Arg::from_usage("-d --debug 'Output debug log.'"),
Arg::from_usage("-q --quiet 'Less output.'"),
Arg::from_usage("--no-output 'Silence all output.'"),
Arg::from_usage("--color=[mode] 'Control color of output.'")
.possible_values(&["off", "auto", "on"])
.default_value("auto"),
])
.get_matches();
SELog::new()
.level(
SELevel::new()
.verbose(m.is_present("verbose"))
.debug(m.is_present("debug"))
.quiet(m.is_present("quiet"))
.off(m.is_present("no-output")),
)
// As the string is validated in the definition, these `unwrap` are safe.
.colorize(Colorize::from_str(m.value_of("color").unwrap()).unwrap())
.init()
.unwrap();
error!("Failed something.");
// ...
}
Re-exports§
Modules§
- Utilities to colorize outputs.
- Define
SELevel
and implement methods.
Structs§
- The SELog struct.
Enums§
- A colour is one specific type of ANSI escape code, and can refer to either the foreground or background colour.