When --debug is supplied, the stderror is not captured to be included in json. Instead, it is emitted as charmguardian's own standard error. But stderror is needed in both places; it's needed in the charmguardian output so that issues can be diagnosed at runtime, and it's needed in the json so that issues can be diagnosed after runtime (end-users should never need to visit Jenkins).
This sort of thing can be done-- /usr/bin/tee both emits output and writes it to a file, for example. In fact, tee could potentially be used as part of the solution to this.
When --debug is supplied, the stderror is not captured to be included in json. Instead, it is emitted as charmguardian's own standard error. But stderror is needed in both places; it's needed in the charmguardian output so that issues can be diagnosed at runtime, and it's needed in the json so that issues can be diagnosed after runtime (end-users should never need to visit Jenkins).
This sort of thing can be done-- /usr/bin/tee both emits output and writes it to a file, for example. In fact, tee could potentially be used as part of the solution to this.