Clean up logging

This commit is contained in:
Einar Forselv
2019-12-04 01:12:26 +01:00
parent c78d208e66
commit 4ff0df1b35
2 changed files with 14 additions and 14 deletions

View File

@@ -51,18 +51,18 @@ def ping_postgres(host, port, username, password) -> int:
def run(cmd: List[str]) -> int:
"""Run a command with parameters"""
logger.info('cmd: %s', ' '.join(cmd))
logger.debug('cmd: %s', ' '.join(cmd))
child = Popen(cmd, stdout=PIPE, stderr=PIPE)
stdoutdata, stderrdata = child.communicate()
if stdoutdata:
logger.info(stdoutdata.decode().strip())
logger.info('-' * 28)
logger.debug(stdoutdata.decode().strip())
logger.debug('-' * 28)
if stderrdata:
logger.info('%s STDERR %s', '-' * 10, '-' * 10)
logger.info(stderrdata.decode().strip())
logger.info('-' * 28)
logger.error('%s STDERR %s', '-' * 10, '-' * 10)
logger.error(stderrdata.decode().strip())
logger.error('-' * 28)
logger.info("returncode %s", child.returncode)
logger.debug("returncode %s", child.returncode)
return child.returncode