From 21ec4cea742b72ef34a822a7124057e9029cd17e Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Wed, 26 Jul 2017 14:50:27 -0400 Subject: [PATCH] ceph-volume: prevent missing conf values for logging config Signed-off-by: Alfredo Deza --- src/ceph-volume/ceph_volume/log.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ceph-volume/ceph_volume/log.py b/src/ceph-volume/ceph_volume/log.py index 0e71d26b64e84..890b6da1b7a5c 100644 --- a/src/ceph-volume/ceph_volume/log.py +++ b/src/ceph-volume/ceph_volume/log.py @@ -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) -- 2.39.5