Drakulix / simplelog.rs

Simple Logging Facility for Rust
https://docs.rs/simplelog/
Apache License 2.0
439 stars 73 forks source link

Ability to select output stream? #31

Closed jmrgibson closed 5 years ago

jmrgibson commented 5 years ago

Is the ability to select whether to log to stdout vs stderr something you consider within the scope of simple log? If so it would be helpful for me. I use simplelog a lot for little terminal utilities, and I'd like the ability for stdout to be the output of the program, with stderr remaining the log output, so I can pipe them into eachother. I'd be willing to take a crack at it.

Drakulix commented 5 years ago

I absolutely do consider this in scope, we just need to come up with a sensible design.

First idea might be to add this to Config, but that is for all loggers and not all loggers log to pipes.

The SimpleLogger (which really should be renamed to something like PrintLogger thinking about it) just uses println! and I do not want to change that either, because that serves as a stable fallback.

With WriteLogger you can already do that, but I guess for your cli-apps the only thing that is really interesting is TermLogger.

Maybe another constructor (new new and init variants), where you can add explicit pipes for error and other logging would be sufficient? This would also allow to keep the current api for the default use-case.

If you come up with a PR, I would very likely merge it.

Drakulix commented 5 years ago

Done in 96f11621b7247f97638ab7e3d688f587aa058ba6