summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Mick <dan.mick@inktank.com>2013-08-22 17:30:24 -0700
committerDan Mick <dan.mick@inktank.com>2013-08-23 15:11:03 -0700
commit2031f391c3df68e0d9e381a1ef3fe58d8939f0a8 (patch)
treef6ef8fc7a31452bc5f4c2253204cad2965b5cfad
parentd26ba3ab0374e77847c742dd00cb3bc9301214c2 (diff)
downloadceph-2031f391c3df68e0d9e381a1ef3fe58d8939f0a8.tar.gz
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 <dan.mick@inktank.com>
-rwxr-xr-xsrc/pybind/ceph_rest_api.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/pybind/ceph_rest_api.py b/src/pybind/ceph_rest_api.py
index 421cc59edcc..c53c3d77737 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.<DEFAULT_ID>'
# '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: