logging: Add journald encoder wrapper#7623
Open
steadytao wants to merge 1 commit intocaddyserver:masterfrom
Open
logging: Add journald encoder wrapper#7623steadytao wants to merge 1 commit intocaddyserver:masterfrom
steadytao wants to merge 1 commit intocaddyserver:masterfrom
Conversation
46401f3 to
d9fa1a4
Compare
Contributor
Contributor
Author
|
My plan will be to make the
I’ll take a look at the cleanest way to do that without making the wrapper too invasive. |
1fc6907 to
ffb1b0d
Compare
Contributor
Author
|
The
That keeps journald’s own timestamp as the one shown by |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Implements the #7611 feature request as an explicit logging encoder wrapper.
Summary
This adds a new
journaldencoder that wraps another encoder and prepends the systemd/journald priority prefix (<N>) to each emitted log line.Example:
Why this shape
The issue discussion converged on keeping this:
That means the wrapped encoder still controls the actual log format (
json,console, etc.), whilejournaldonly adds the priority prefix that journald understands for stdout/stderr log streams.This encoder does not write directly to journald.
Behaviour
Priority mapping currently follows the standard journald/syslog severity levels:
debug-><7>info-><6>warn-><4>error-><3>dpanic/panic/fatal-><2>If no wrapped encoder is specified, it follows the same default behavior as the existing wrapper encoders:
jsonconsolefor terminal outputTests
Added:
format journald { wrap console }EDIT
Updated to also suppress the wrapped encoder’s timestamp by default when using
format journald.That means:
wrap consoleno longer includes the in-line timestampwrap jsonno longer includes thetsfieldThe intent is to avoid duplicating timestamp information that journald /
journalctlalready provides separately. Should be mentioned explicitly.Implements + should close #7611.
Assistance Disclosure
No AI was used.