]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: log: notify to stdout if it is not possible to write to the log location
authorAlfredo Deza <adeza@redhat.com>
Thu, 22 Jun 2017 21:15:49 +0000 (17:15 -0400)
committerAlfredo Deza <adeza@redhat.com>
Fri, 4 Aug 2017 14:25:57 +0000 (10:25 -0400)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
src/ceph-volume/ceph_volume/log.py

index 6a12e670846ce097376d7d7fcdd950d8ff230792..b78752acea6e7b3f3285980e2a3d60a22ae1ea4f 100644 (file)
@@ -1,12 +1,12 @@
 import logging
 import os
-from ceph_volume import config
+from ceph_volume import config, terminal
 
 BASE_FORMAT = "[%(name)s][%(levelname)-6s] %(message)s"
 FILE_FORMAT = "[%(asctime)s]" + BASE_FORMAT
 
 
-def setup(config=None, name='ceph-volume.log'):
+def setup(name='ceph-volume.log'):
     # 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
@@ -24,7 +24,9 @@ def setup(config=None, name='ceph-volume.log'):
     config['log_path'] = log_file
     try:
         fh = logging.FileHandler(log_file)
-    except (OSError, IOError):
+    except (OSError, IOError) as err:
+        terminal.warning("Falling back to /tmp/ for logging. Can't use %s" % log_file)
+        terminal.warning(str(err))
         config['log_path'] = tmp_log_file
         fh = logging.FileHandler(tmp_log_file)