From: Alfredo Deza Date: Thu, 22 Jun 2017 21:15:49 +0000 (-0400) Subject: ceph-volume: log: notify to stdout if it is not possible to write to the log location X-Git-Tag: ses5-milestone10~3^2~5^2~94 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ebf56e7df31a945fbf5b7bbec74dbb54b10b9a47;p=ceph.git ceph-volume: log: notify to stdout if it is not possible to write to the log location Signed-off-by: Alfredo Deza --- diff --git a/src/ceph-volume/ceph_volume/log.py b/src/ceph-volume/ceph_volume/log.py index 6a12e670846c..b78752acea6e 100644 --- a/src/ceph-volume/ceph_volume/log.py +++ b/src/ceph-volume/ceph_volume/log.py @@ -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)