rust-cli / env_logger

A logging implementation for `log` which is configured via an environment variable.
https://docs.rs/env_logger
Apache License 2.0
803 stars 125 forks source link

Journald #194

Open imbolc opened 3 years ago

imbolc commented 3 years ago

My question is similar to #178, but about systemd journal as an additional target. Systemd crate already exposes log_record() as a part of its public api. What do you think about adding it as a dependency behind a feature-flag?

jplatte commented 3 years ago

Would this approach work for journald integration?

imbolc commented 3 years ago

It could be done with a trait object, but I'm afraid std::io::Write wont be enough, as it consumes just bytes. Journald stores structured data so it would need log level and all the logged variables if kv_unstable feature is enabled.

jplatte commented 3 years ago

I see. Well I'm afraid I'm only doing light maintenance here and can't really provide more than a few cross links.

CC @KodrAus

imbolc commented 3 years ago

I found it's easy to make it with tracing, in case someone else will need this: https://gist.github.com/imbolc/f75f924f66c129f0e1e910f59fb75c0d

swsnr commented 3 years ago

I wrote a wrapper to use the filter part of env_logger with any Log implementation (https://gist.github.com/lunaryorn/a2f63c6daa11fabec764caeb8a65dd00) which I use together with a separate journal logging crate

TornaxO7 commented 2 years ago

Are there any updates for this one yet?