ginkgo icon indicating copy to clipboard operation
ginkgo copied to clipboard

JSON output to stdout

Open scotty3005 opened this issue 1 year ago • 5 comments

Hi, is there a way to avoid printing anything but what produced by reporting nodes to stdout? We would need to have on stdout only JSON formatted ouput for logging purposes, and we're thinking to use reporting nodes for that. However ever it seems not possible to mute all others ginkgo outputs. Thanks

scotty3005 avatar Nov 12 '24 22:11 scotty3005

hey - that is not currently supported. it would not be too hard to add a -mute option or something. if you’re interested in submitting a PR I can show you were to make adjustments.

onsi avatar Nov 14 '24 13:11 onsi

Hi I would be happy to contribute if I'll have some time. Please show me where can I add the changes. Thanks!

scotty3005 avatar Nov 18 '24 17:11 scotty3005

hey there, sure thing. i'm not 100% confident this is all you need to do. But a rough outline:

  • Add a new mute flag to the ReporterConfig and flagset in https://github.com/onsi/ginkgo/blob/master/types/config.go
  • Have the core DSL create a NoopReporter{} instead of a DefaultReporter if the mute flag is set: https://github.com/onsi/ginkgo/blob/master/core_dsl.go#L261 (This will cover the case when running in series)
  • When running in parallel the output is actually coming from the CLI - so you'll want to pass NoopReporter in to the parallel server if the mute flag is set: https://github.com/onsi/ginkgo/blob/master/ginkgo/internal/run.go#L174
  • You'll then want to add an integration test. Probably in this file: https://github.com/onsi/ginkgo/blob/master/integration/reporting_test.go
  • And, lastly, you'll want to update the docs to describe the -mute flag. Probably somewhere here: https://github.com/onsi/ginkgo/blob/master/docs/index.md#controlling-verbosity

onsi avatar Nov 24 '24 03:11 onsi

Hi @onsi, please let me know if this is still open, I am ready to pick it up.

tdadadavid avatar Feb 22 '25 01:02 tdadadavid

hey so so sorry for the delay. yes it's totally available and ready to be picked up (if you still have the time!!) and the outline i shared still holds but let me know if you run into issues or it doens't make sense (i'll aim to be more responsive, going forward - sorry about that)

onsi avatar Mar 05 '25 17:03 onsi