]>
git.proxmox.com Git - ceph.git/blob - ceph/src/ceph-volume/ceph_volume/log.py
3 from ceph_volume
import terminal
4 from ceph_volume
import conf
6 BASE_FORMAT
= "[%(name)s][%(levelname)-6s] %(message)s"
7 FILE_FORMAT
= "[%(asctime)s]" + BASE_FORMAT
10 def setup(name
='ceph-volume.log', log_path
=None):
11 log_path
= log_path
or conf
.log_path
12 # if a non-root user calls help or other no-sudo-required command the
13 # logger will fail to write to /var/lib/ceph/ so this /tmp/ path is used as
15 tmp_log_file
= os
.path
.join('/tmp/', name
)
16 root_logger
= logging
.getLogger()
17 # The default path is where all ceph log files are, and will get rotated by
18 # Ceph's logrotate rules.
20 root_logger
.setLevel(logging
.DEBUG
)
23 fh
= logging
.FileHandler(log_path
)
24 except (OSError, IOError) as err
:
25 terminal
.warning("Falling back to /tmp/ for logging. Can't use %s" % log_path
)
26 terminal
.warning(str(err
))
27 conf
.log_path
= tmp_log_file
28 fh
= logging
.FileHandler(tmp_log_file
)
30 fh
.setLevel(logging
.DEBUG
)
31 fh
.setFormatter(logging
.Formatter(FILE_FORMAT
))
33 root_logger
.addHandler(fh
)