Sometimes you can log too much. For example, logging a complete
iptables dump on every security group operation, OMG TMI. Doing this
during DSVM run results in a log file >7M compressed. To mitigate this
issue this commit switches the execute method to only log the command
and it's exit code on the success case. If there is a failure the
entire stdin, stdout and stderr are logged.
Change-Id: Iaf17297306dc752e666612033c805a528f078f2f
except UnicodeError:
pass
- m = _("\nCommand: {cmd}\nExit code: {code}\nStdin: {stdin}\n"
- "Stdout: {stdout}\nStderr: {stderr}").format(
+ m = _("\nCommand: {cmd}\nExit code: {code}\n").format(
cmd=cmd,
- code=returncode,
- stdin=process_input or '',
- stdout=_stdout,
- stderr=_stderr)
+ code=returncode)
extra_ok_codes = extra_ok_codes or []
if returncode and returncode in extra_ok_codes:
returncode = None
if returncode and log_fail_as_error:
+ m += ("Stdin: {stdin}\n"
+ "Stdout: {stdout}\nStderr: {stderr}").format(
+ stdin=process_input or '',
+ stdout=_stdout,
+ stderr=_stderr)
LOG.error(m)
else:
LOG.debug(m)