matrix-org / go-neb

Extensible matrix bot written in Go
Apache License 2.0
283 stars 91 forks source link

Support for journald logging #359

Open peterhoeg opened 3 years ago

peterhoeg commented 3 years ago

Is your feature request related to a problem? Please describe.

The default logger logs superflous info when logging to journald (of systemd fame):

Sep 06 12:04:53 day go-neb[2212178]: time="2021-09-06T12:04:53+08:00" level=info msg="Inserted 1 clients"

Describe the solution you'd like

journald handles both the level and timestamp, so all we really need is:

Sep 06 12:04:53 day go-neb[2212178]: msg="Inserted 1 clients"

It's possible to detect if you're running under systemd (and thus logging to journald) by checking for the environment variable INVOCATION_ID.

Describe alternatives you've considered

An alternative is to do proper logging of structured data to journald when detected which would be nice (and which would also solve all of this), but just getting rid of the duplicate information would be an excellent first step.