From ebf56e7df31a945fbf5b7bbec74dbb54b10b9a47 Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Thu, 22 Jun 2017 17:15:49 -0400 Subject: [PATCH] ceph-volume: log: notify to stdout if it is not possible to write to the log location Signed-off-by: Alfredo Deza --- src/ceph-volume/ceph_volume/log.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ceph-volume/ceph_volume/log.py b/src/ceph-volume/ceph_volume/log.py index 6a12e670846ce..b78752acea6e7 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) -- 2.39.5