Hrm, yeah, playing around with the capture_output method from Saikuro (sorry I didn't catch that it existed earlier), it looks like it would do the trick without requiring these changes from STDOUT to $stdout. Would you prefer I expose the Saikuro version in a common place in the MetricFu library and use it instead? Happy to do that.