allow customizing log prefixes for wasmtime serve command #9821
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.
What
As discussed in feature request: #9799,
wasmtime serve
command always prefixes stdout and stderr logs of wasi-http handler with hardcoded format. This prevents user to implement consistent logging formats like json logging.This PR adds an optional flags,
--no-logging-prefix
, to stop adding log prefixes. When the new flags are not provided, existing hehaviour is preserved.Test
Alternatives
I know adding flags to CLI creates long term promise, so I'm trying to be careful here and have considered a few alternatives.
boolean flags vs string
(original implementation in this PR) To allow better flexibility and future proof, we could add two string flags,
--logging-prefix-stdout
and--logging-prefix-stderr
, which allows users to customize the prefix, and possibly removing the prefix by providing empty strings. This enables future possibilities like allow users to specify log prefixes with templates, as the{ req_id }
could be useful. this is replaced with simple boolean flag of--no-logging-prefix
to avoid over engineering.Debug options
The existing
DebugOptions
already contains some customization about loggingwasmtime/crates/cli-flags/src/lib.rs
Lines 241 to 244 in da93f64
While we could add the flags there, I feel the new flags in this PR are specific to
wasmtime serve
command. So adding them to the common flags might confuse people for other commands.