env_logger icon indicating copy to clipboard operation
env_logger copied to clipboard

Trivial: the systemd example misuses RUST_LOG_STYLE

Open iustin opened this issue 2 years ago • 1 comments

I might be wrong, but the systemd example (added in #157) overloads RUST_LOG_STYLE. Since that is parsed internally by env_logger, I think the example is suboptimal; it would be better to control the systemd-vs-non-systemd and style separately, as long as systemd is not directly supported (which would be best, actually, as a new WriteStyle).

I might misunderstand the way the WriteStyle is supposed to work though, not sure.

iustin avatar Nov 14 '23 22:11 iustin

Also, the example given has this error in it

error[E0599]: cannot write into `&mut env_logger::fmt::Formatter`
  --> src/main.rs:26:5
   |
25 | /             writeln!(
26 | |                 buf,
   | |                 ^^^
27 | |                 "<{}>{}: {}",
28 | |                 match record.level() {
...  |
36 | |                 record.args()
37 | |             )
   | |_____________- method not found in `&mut Formatter`
   |
note: must implement `io::Write`, `fmt::Write`, or have a `write_fmt` method
  --> src/main.rs:26:5
   |
26 |                 buf,
   |                 ^^^
   = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
   |
1  + use std::io::Write;
   |

Gunni avatar Jan 12 '24 16:01 Gunni