]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph_rest_api.py: create own default for log_file 531/head
authorDan Mick <dan.mick@inktank.com>
Fri, 23 Aug 2013 00:30:24 +0000 (17:30 -0700)
committerDan Mick <dan.mick@inktank.com>
Fri, 23 Aug 2013 22:11:03 +0000 (15:11 -0700)
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>
src/pybind/ceph_rest_api.py

index 421cc59edcc07d497e22636ebb3fd0d6a186966b..c53c3d77737a8d73ac7fe11b550e4bc705a6cfb1 100755 (executable)
@@ -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: