Closed quality-leftovers closed 2 months ago
Thank you for reporting this. The easiest solution would be to set hclog.LoggerOptions.JSONFormat = true
if the JSON format is specified in the flags. This could be passed in using a new field in the PluginHook
struct. Would you be willing to open a PR for this?
Describe the bug Using
-log-format=json
does not apply to logging of (hc)pluginTo Reproduce Steps to reproduce the behavior:
-log-format=json
and (hc)plugin hookExpected behavior All logs are formatted as json
Setup details I tried using both "log" and hc-log in the plugin.
Initializing the logger in the plugin using
does not produce the desired results.
Instead I had to add
JSONFormat: true,
to https://github.com/tus/tusd/blob/50b9ff5623c26c856ec97e2e0a9a44c0f6baaceb/pkg/hooks/plugin/plugin.go#L36-L40It would be nice to either pass the Json flag to the hclogger instance or if something like an hclog->slog adapter was use d (like https://github.com/evanphx/go-hclog-slog, but in the opposite direction. Not sure if such a package exists / is possible)
Log output "as is"
Log output using: https://github.com/quality-leftovers/tusd/tree/plugin-log-json