instance.py

changeset 31
b4b4bb7a2ec5
parent 29
9dd2e5d57a7c
child 32
06fc14211ba9
--- a/instance.py	Sun Jan 21 12:10:57 2018 +0000
+++ b/instance.py	Sun Jan 21 13:34:12 2018 +0000
@@ -8,6 +8,8 @@
 from subprocess import Popen, PIPE
 from config import settings, arglistify
 
+logger=logging.getLogger(__name__)
+
 necessary_opts=['--log-json', '--progress']
 
 necessary_opts_for={
@@ -39,7 +41,7 @@
     def launch(self, passphrase=None):
         cmd=self.construct_cmdline()
 
-        logging.info('Launching ' + str(cmd))
+        logger.info('Launching ' + str(cmd))
 
         env=os.environ.copy()
         if passphrase:
@@ -64,13 +66,13 @@
         stream=self.proc.stdout
         line=stream.read(-1)
         if line==b'':
-            logging.debug('Borg stdout pipe EOF?')
+            logger.debug('Borg stdout pipe EOF?')
             return None
 
         try:
             return json.loads(line)
         except:
-            logging.warning('JSON parse failed on: "%s"' % line)
+            logger.warning('JSON parse failed on: "%s"' % line)
             return None
 
     def read_log(self):
@@ -78,7 +80,7 @@
         try:
             line=stream.readline()
         except err:
-            logging.debug('Pipe read failed: %s' % str(err))
+            logger.debug('Pipe read failed: %s' % str(err))
 
             return {'type': 'log_message',
                     'levelname': 'CRITICAL',
@@ -88,7 +90,7 @@
 
         if line==b'':
 
-            logging.debug('Borg stderr pipe EOF?')
+            logger.debug('Borg stderr pipe EOF?')
 
             return None
 
@@ -98,7 +100,7 @@
                 res['type']='UNKNOWN'
             return res
         except:
-            logging.debug('JSON parse failed on: "%s"' % str(line))
+            logger.debug('JSON parse failed on: "%s"' % str(line))
 
             errmsg=line
             for line in iter(stream.readline, b''):

mercurial