From afef3ee71136bb2d6631bafc731af94b0e3444d1 Mon Sep 17 00:00:00 2001 From: Eric Torres Date: Thu, 18 Apr 2019 21:46:33 -0700 Subject: [PATCH] Log at the exception level, not at the library level for rsync --- bin/backup | 1 + rbackup/rsync.py | 9 ++------- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/bin/backup b/bin/backup index 971bb95..ab70b69 100644 --- a/bin/backup +++ b/bin/backup @@ -167,6 +167,7 @@ if __name__ == "__main__": except CalledProcessError as e: syslog.critical("Backup process failed") syslog.critical(f"Failing command: {e.cmd}") + syslog.critical(e.stderr) exit(e.returncode) if args.run_post_sync: diff --git a/rbackup/rsync.py b/rbackup/rsync.py index a0b9ff1..3ccfe21 100644 --- a/rbackup/rsync.py +++ b/rbackup/rsync.py @@ -28,7 +28,7 @@ syslog = logging.getLogger(__name__) def rsync(*args): """Run an rsync command. - :param args: all arguments to pass to rsync + :param args: all arguments to pass to rsync including source and destination :type args: str :raises subprocess.CalledProcessError: if rsync process failed """ @@ -37,12 +37,7 @@ def rsync(*args): syslog.debug(f"rsync command: {cmd}") syslog.info("Beginning rsync process") - try: - process = subprocess.run(cmd, capture_output=True, check=True, text=True) - except subprocess.CalledProcessError as e: - syslog.error(e.stderr) - syslog.debug(e.stdout) - raise e + process = subprocess.run(cmd, capture_output=True, check=True, text=True) syslog.debug(process.stdout) syslog.info("Process complete")