goexpect icon indicating copy to clipboard operation
goexpect copied to clipboard

Having two SpawnGeneric, each with different verbosity configuration

Open oshoval opened this issue 3 years ago • 0 comments

Hi We are using goexpect at https://github.com/kubevirt/kubevirt [1] With the following settings to SpawnGeneric:

opts = append(opts, expect.Verbose(true))
opts = append(opts, expect.VerboseWriter(GinkgoWriter))

[1] https://github.com/kubevirt/kubevirt/blob/75674879e91dfc24a340cae54c92ea7509e42cb4/tests/console/console.go#L209

On one hand it is perfect for us that only upon error or verbose mode, we see all the logged info. The problem is that if there is an error, we have a custom error reporter, which also uses SpawnGeneric in order to trigger some more commands that collect data. Those commands would print as well all the collected info to the console, which cause it to be too loaded with info which is not needed (it is saved to files as well where it belongs).

Is there a way to have two SpawnGeneric, where one prints to GinkgoWriter, while the other prints to /dev/null or doesn't print at all ?

Tried few configurations, but no luck yet (changes might be required in the NewExpecter as well i believe) For example tried to have a different buffer and control it (I believe I didn't do it right if it suppose to work)

Thanks

oshoval avatar Jun 19 '22 12:06 oshoval