logging instead of printing

Change-Id: I0a7ebc150ed06976c5c8528fd0467c89b78b21f7
diff --git a/rsync_client.py b/rsync_client.py
index 61977b8..944b74b 100644
--- a/rsync_client.py
+++ b/rsync_client.py
@@ -3,12 +3,16 @@
 
 
 import datetime
+import logging
 import os
 import re
 import subprocess
 import tempfile
 
 
+logging.basicConfig(level=logging.INFO)
+logger = logging.getLogger('rsync_staging')
+
 now = datetime.datetime.utcnow()
 staging_snapshot_stamp_format = r'%Y-%m-%d-%H%M%S'
 staging_snapshot_stamp_regexp = r'[0-9]{4}-[0-9]{2}-[0-9]{2}-[0-9]{6}'
@@ -105,19 +109,21 @@
         return linkname
 
     def _shell(self, cmd, raise_error=True):
-        print cmd
+        logger.info(cmd)
         process = subprocess.Popen(cmd,
                                    stdin=subprocess.PIPE,
                                    stdout=subprocess.PIPE,
                                    stderr=subprocess.PIPE,
                                    shell=True)
         out, err = process.communicate()
+        logger.debug(out)
         exitcode = process.returncode
         if process.returncode != 0 and raise_error:
             msg = '"{cmd}" failed. Exit code == {exitcode}'\
                   '\n\nSTDOUT: \n{out}'\
                   '\n\nSTDERR: \n{err}'\
                   .format(**(locals()))
+            logger.error(msg)
             raise RuntimeError(msg)
         return exitcode, out, err
 
@@ -191,7 +197,7 @@
             self._remove_old_snapshots()
             return exitcode, out, err
         except RuntimeError as e:
-            print e.message
+            logger.error(e.message)
             self.rsync_delete_dir(self.staging_dir_path)
             raise
 
@@ -202,8 +208,8 @@
                 or save_last_days is False \
                 or save_last_days == 0:
             # skipping deletion if save_last_days == None or False or 0
-            print 'Skip deletion of old snapshots because of '\
-                  'save_last_days == {}'.format(save_last_days)
+            logger.info('Skip deletion of old snapshots because of '
+                        'save_last_days == {}'.format(save_last_days))
             return
         warn_date = now - datetime.timedelta(days=save_last_days)
         warn_date = datetime.datetime.combine(warn_date, datetime.time(0))
@@ -230,5 +236,5 @@
                 if not dir_links:
                     self.rsync_delete_dir(dir_path)
                 else:
-                    print 'Skip deletion of "{}" because there are '\
-                          'symlinks found: {}'.format(d, dir_links)
+                    logger.info('Skip deletion of "{}" because there are '
+                                'symlinks found: {}'.format(d, dir_links))