allow customizing log prefixes for wasmtime serve command#9821
Conversation
Signed-off-by: Joseph Zhang <jzhang@absolute.com>
alexcrichton
left a comment
There was a problem hiding this comment.
Thanks! I think the documentation may want to be updated though because using {req_id} could be confusing as the prefix here doesn't actually support interpolation of req_id or other variables. If there's no need to have acustom prefixes it might also be reasonable to have a single flag to disable prefixes perhaps?
Thanks for the review. I see that you are suggesting two directions, one to keep the custom prefix flags but update the documentation to remove mention of I'm fine with either approach, so please just let me know which is your preference and I'll update accordingly. thanks :) |
|
Ah yes sorry, I also don't have much of a preference. Since your goal is to just disable the prefix why don't we add that for now and consider adding customizable ones later. |
What
As discussed in feature request: #9799,
wasmtime servecommand 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-stdoutand--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-prefixto avoid over engineering.Debug options
The existing
DebugOptionsalready 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 servecommand. So adding them to the common flags might confuse people for other commands.