simplelog Build Status Build status Coverage Status Crates.io Crates.io

A simple and easy-to-use logging facility for Rust's log crate

simplelog does not aim to provide a rich set of features, nor to provide the best logging solution. It aims to be a maintainable, easy to integrate facility for small to medium sized projects, that find env_logger to be somewhat lacking in features. In those cases simplelog should provide an easy alternative.

Concept

simplelog provides a series of logging facilities, that can be easily combined.

Usage

```rust

[macro_use]extern crate log;

extern crate simplelog;

use simplelog::{Config, TermLogger, WriteLogger, CombinedLogger, LogLevelFilter};

use std::fs::File;

fn main() { CombinedLogger::init( vec![ TermLogger::new(LogLevelFilter::Warn, Config::default()), WriteLogger::new(LogLevelFilter::Info, Config::default(), File::create("myrustbinary.log").unwrap()), ] ).unwrap();

error!("Bright red error");
info!("This only appears in the log file");
debug!("This level is currently not enabled for any logger");

} ```

Results in

$ cargo run --example usage Compiling simplelog v0.1.0 (file:///home/drakulix/Projects/simplelog) Running `target/debug/examples/usage` [ERROR] Bright red error and myrustbinary.log 11:13:03 [ERROR] usage: Bright red error 11:13:03 [INFO] usage: This only appears in the log file

Getting Started

Just add [dependencies] simplelog = "^0.4.0" to your Cargo.toml

Documentation

Contributing

If you wish to contribute your own logger to simplelog or advance/extend existing loggers, feel free to create a pull request. Just don't blindly assume, that your logger will be accepted. The rational about this library is, that it is simple to use. This mostly comes down to a small and easy API, but also includes things like the amount of added dependencies. If you feel unsure about your plans, feel free to create an issue to talk about your ideas.

Happy Coding!