Add logging support for rsync module
This commit is contained in:
		@@ -3,6 +3,7 @@
 | 
				
			|||||||
.. module:: rbackup.rsync
 | 
					.. module:: rbackup.rsync
 | 
				
			||||||
    :synopsis: helper functions for running the rsync backend
 | 
					    :synopsis: helper functions for running the rsync backend
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
 | 
					import logging
 | 
				
			||||||
import subprocess
 | 
					import subprocess
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -10,6 +11,9 @@ import subprocess
 | 
				
			|||||||
_RSYNC_BIN = "/usr/bin/rsync"
 | 
					_RSYNC_BIN = "/usr/bin/rsync"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# ========== Logging Setup ===========
 | 
				
			||||||
 | 
					syslog = logging.getLogger(__name__)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# ========== Functions ==========
 | 
					# ========== Functions ==========
 | 
				
			||||||
def rsync(*args):
 | 
					def rsync(*args):
 | 
				
			||||||
    """Run an rsync command.
 | 
					    """Run an rsync command.
 | 
				
			||||||
@@ -19,4 +23,14 @@ def rsync(*args):
 | 
				
			|||||||
    :raises: subprocess.CalledProcessError if rsync process failed
 | 
					    :raises: subprocess.CalledProcessError if rsync process failed
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
    cmd = [_RSYNC_BIN, *args]
 | 
					    cmd = [_RSYNC_BIN, *args]
 | 
				
			||||||
    subprocess.run(cmd, capture_output=True, check=True)
 | 
					
 | 
				
			||||||
 | 
					    syslog.debug(f"rsync command: {cmd}")
 | 
				
			||||||
 | 
					    syslog.info("Beginning rsync process")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    try:
 | 
				
			||||||
 | 
					        process = subprocess.run(cmd, capture_output=True, check=True)
 | 
				
			||||||
 | 
					    except subprocess.CalledProcessError as e:
 | 
				
			||||||
 | 
					        raise e
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    syslog.debug(process.stdout)
 | 
				
			||||||
 | 
					    syslog.info("Process complete")
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user