Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

journald: Don't prefix message_id field to make use of Journal Message Catalogs easier #3111

Open
wants to merge 1 commit into
base: v0.1.x
Choose a base branch
from

Conversation

MattesWhite
Copy link

Do not prefix event fields named message_id just like fields named message to enable easy use of Journal Message Catalogs.

Motivation

Viewing the structured fields recorded in journald is very verbose and cumbersome.

One option is to use Journal Message Catalogs. journald catalogs provide templates that render log events with more information. They also support placeholders that get replaced by structured fields. This way it is way easier to access structured fields and inspect logs via journalctl -x.

Log events and catalog entries are matched by the MESSAGE_ID. It is already possible to set the message_id field in tracing's log macros but only if no prefix is used. In contrast to message, message_id is not a special field and is therefore not exempt from prefixing. As a result, using Journal Message Catalogs, tracing-journald, and a prefix is currently not possible.

Solution

This PR simply exempts fields named message_id from prefixing just like for fields called message.

Future work

This PR is the first step to make using tracing-journald and Journal Message Catalogs together easier. I have a few ideas how this integration can be further improved, like creating catalog files from source code or generate specific log macros from catalog files, but this is way out of scope for this PR and maybe even this crate. However, this needs more discussions.

Target branch

This PR targets the v0.1.x branch as it holds the latest version of trancing-journald that is also published on crates.io. If this is not the correct target branch I'll gladly change it.

This allows using journald message catalogs in combination with
tracing-journald and a prefix.

See also: https://systemd.io/CATALOG/
@MattesWhite MattesWhite requested review from hawkw and a team as code owners October 18, 2024 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant