From: Dan Mick Date: Fri, 23 Aug 2013 00:30:24 +0000 (-0700) Subject: ceph_rest_api.py: create own default for log_file X-Git-Tag: v0.68~11^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F531%2Fhead;p=ceph.git ceph_rest_api.py: create own default for log_file common/config thinks the default log_file for non-daemons should be "". Override that so that the default is /var/log/ceph/{cluster}-{name}.{pid}.log since ceph-rest-api is more of a daemon than a client. Fixes: #6099 Backport: dumpling Signed-off-by: Dan Mick --- diff --git a/src/pybind/ceph_rest_api.py b/src/pybind/ceph_rest_api.py index 421cc59edcc0..c53c3d77737a 100755 --- a/src/pybind/ceph_rest_api.py +++ b/src/pybind/ceph_rest_api.py @@ -5,6 +5,7 @@ import errno import json import logging import logging.handlers +import os import rados import textwrap import xml.etree.ElementTree @@ -26,6 +27,7 @@ DEFAULT_ID = 'restapi' DEFAULT_BASEURL = '/api/v0.1' DEFAULT_LOG_LEVEL = 'warning' +DEFAULT_LOGDIR = '/var/log/ceph' # default client name will be 'client.' # 'app' must be global for decorators, etc. @@ -117,7 +119,18 @@ def api_setup(app, conf, cluster, clientname, clientid, args): loglevel = app.ceph_cluster.conf_get('restapi_log_level') \ or DEFAULT_LOG_LEVEL + # ceph has a default log file for daemons only; clients (like this) + # default to "". Override that for this particular client. logfile = app.ceph_cluster.conf_get('log_file') + if not logfile: + logfile = os.path.join( + DEFAULT_LOGDIR, + '{cluster}-{clientname}.{pid}.log'.format( + cluster=cluster, + clientname=clientname, + pid=os.getpid() + ) + ) app.logger.addHandler(logging.handlers.WatchedFileHandler(logfile)) app.logger.setLevel(LOGLEVELS[loglevel.lower()]) for h in app.logger.handlers: