]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
ceph-volume: prevent missing conf values for logging config
authorAlfredo Deza <adeza@redhat.com>
Wed, 26 Jul 2017 18:50:27 +0000 (14:50 -0400)
committerAlfredo Deza <adeza@redhat.com>
Fri, 4 Aug 2017 14:25:58 +0000 (10:25 -0400)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
src/ceph-volume/ceph_volume/log.py

index 0e71d26b64e84479e21b70b1bdf1d6f3b964acae..890b6da1b7a5c04b01a6652e1f768c00b5aafc8f 100644 (file)
@@ -7,7 +7,8 @@ BASE_FORMAT = "[%(name)s][%(levelname)-6s] %(message)s"
 FILE_FORMAT = "[%(asctime)s]" + BASE_FORMAT
 
 
-def setup(name='ceph-volume.log'):
+def setup(name='ceph-volume.log', log_path=None):
+    log_path = log_path or conf.log_path
     # if a non-root user calls help or other no-sudo-required command the
     # logger will fail to write to /var/lib/ceph/ so this /tmp/ path is used as
     # a fallback
@@ -19,9 +20,9 @@ def setup(name='ceph-volume.log'):
     root_logger.setLevel(logging.DEBUG)
 
     try:
-        fh = logging.FileHandler(conf.log_path)
+        fh = logging.FileHandler(log_path)
     except (OSError, IOError) as err:
-        terminal.warning("Falling back to /tmp/ for logging. Can't use %s" % conf.log_path)
+        terminal.warning("Falling back to /tmp/ for logging. Can't use %s" % log_path)
         terminal.warning(str(err))
         conf.log_path = tmp_log_file
         fh = logging.FileHandler(tmp_log_file)