diff --git a/pkg/output/output.go b/pkg/output/output.go index c2febf9f..33375852 100644 --- a/pkg/output/output.go +++ b/pkg/output/output.go @@ -262,6 +262,16 @@ func (w *StandardWriter) WriteErr(errMessage *Error) error { w.outputMutex.Lock() defer w.outputMutex.Unlock() + // Write to stdout when JSON output is enabled + if w.json { + gologger.Silent().Msgf("%s", string(data)) + if w.outputFile != nil { + if err := w.outputFile.Write(data); err != nil { + return errkit.Wrap(err, "output: write error to output file") + } + } + } + if w.errorFile != nil { if err := w.errorFile.Write(data); err != nil { return errkit.Wrap(err, "output: write to error file")