# twyg
[![][logo]][logo-large]
*A tiny logging setup for Rust applications*
I got used to logging my apps in Clojure with [Twig](https://github.com/clojusc/twig)
and in LFE with [Logjam](https://github.com/lfex/logjam), so here this is.
## Usage
I like to put my logging setup in YAML config files for my apps, but however
you prefer to do that, you'll need to eventually populate the
`twyg::LoggerOpts` struct:
```rust
let opts = twyg::LoggerOpts{
colored: true,
file: "".to_string(),
level: "debug".to_string(),
report_caller: true,
};
```
Options:
* `colored`: setting to false will disable ANIS colors in the logging output
* `file`: provide a path to a file, and output will be logged there too
* `level`: case-insensitive logging level
* `report_caller`: setting to true will output the filename and line number
where the logging call was made
With the opts defined, make the setup call:
```rust
match twyg::setup_logger(&opts) {
Ok(_) => {},
Err(error) => {
panic!("Could not setup logger: {:?}", error)
},
};
```
All subsequent calls to the standard Rust log functions will use this setup,
providing output like the following:
[![][screenshot-thumb]][screenshot]
The output in the screenshot above (click for a a full-sized view) is from
running the little demo in [main.rs](src/main.rs).
[logo]: resources/images/logo-250x.png
[logo-large]: resources/images/logo-1000x.png
[screenshot-thumb]: resources/images/screenshot-thumb.png
[screenshot]: resources/images/screenshot.png