Drakulix / simplelog.rs

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

Select a different output fd #62

Closed Veetaha closed 4 years ago

Veetaha commented 4 years ago

Hi, this crate is a perfect low-overhead logger implementation I want. However, from my point of view, human-readable logs should go to stderr instead of stdout. Would it be possible to add some configuration to select stderr or stdout output for the crate? Maybe through a cargo feature or via an init function?

Drakulix commented 4 years ago

Already possible for TermLogger! You can initialize it with a TerminalMode, which can either be stdout/stderr or mixed-mode.

You could also manually initialize WriteLogger with any type implementing Write, which also applies to std::io::Stderr. But you would miss out on colored output.

Only SimpleLogger just uses println! internally and will always write to stdout. But I would accept a PR to make SimpleLogger configurable (similar to TermLogger) to use eprintln! instead.

Veetaha commented 4 years ago

Oh, I think I have mistaken this project with https://github.com/borntyping/rust-simple_logger The issue is that simplelog.rs unconditionally depends on chrono, but I would like a logger with 0 dependencies which outputs to stderr...

Drakulix commented 4 years ago

Well, I would certainly accept a PR, that makes chrono optional and just disables time-formatting/output, if you are interested.

Anyway, I guess the original issue is resolved. Feel free to open another one on the subject, if needed.