journal: SendVals with arbitrary auto-converting functions #454
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.
Hello,
I am working on log/slog handler implementation for our project using this library and the API does only allow passing journald fields as a map of strings. The
log/slog
implementation is designed around slices of attributes (with some array-based optimalization hacks to decrease allocation count), I would like to follow the suit and avoid conversion to maps.This patch adds new function
SendVals
andValue
interface which allows the API users to use alternative syntax to provide journald values:The whole suite of helper fucntions is provided, but they immediately convert the value to string since carrying the type does not make much sense in this case as the value is immediately written to byte buffer and sent to journald. It is just a syntactic sugar I thought might be useful, for my usecase only the
journal.String
is enough.Keeping all those options is useful because all are named in a same fasion as in the official
log/slog
logging library so people might be familiar with it this way.