From: John Spray Date: Thu, 30 Jun 2016 23:28:16 +0000 (+0100) Subject: pybind/mgr: fix django request logging X-Git-Tag: v11.0.1~60^2~47 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=cc0b8fb7c1e5ec29d7bd29545785d141ba3c3c5e;p=ceph.git pybind/mgr: fix django request logging This was going to a text file, hook it in to the proper logging. Signed-off-by: John Spray --- diff --git a/src/pybind/mgr/calamari_rest/settings.py b/src/pybind/mgr/calamari_rest/settings.py index 4d555d59866..7d60bdaeb24 100644 --- a/src/pybind/mgr/calamari_rest/settings.py +++ b/src/pybind/mgr/calamari_rest/settings.py @@ -122,31 +122,7 @@ INSTALLED_APPS = ( # See http://docs.djangoproject.com/en/dev/topics/logging for # more details on how to customize your logging configuration. LOGGING = { - 'version': 1, - 'disable_existing_loggers': False, - 'formatters': { - 'simple': { - 'format': "%(asctime)s - %(levelname)s - %(name)s %(message)s" - } - }, - 'handlers': { - 'log_file': { - 'class': 'logging.handlers.WatchedFileHandler', - 'filename': - # FIXME: populate configuration like log path from up in - # the C++ layer where we have our ceph config_opts - "/tmp/pyfoo.log", - 'formatter': 'simple' - }, - }, - 'loggers': { - 'django.request': { - 'handlers': ['log_file'], - # FIXME: populate log level from C++-land configuration - 'level': "DEBUG", - 'propagate': True, - }, - } + } diff --git a/src/pybind/mgr/mgr_module.py b/src/pybind/mgr/mgr_module.py index 2813e42793e..d1e92a57a8b 100644 --- a/src/pybind/mgr/mgr_module.py +++ b/src/pybind/mgr/mgr_module.py @@ -37,6 +37,10 @@ class MgrModule(object): self._handle = handle self._logger = logging.getLogger(handle) + # FIXME: we should learn the log level from C++ land, and then + # avoid calling ceph_state.log when we know a message is of + # an insufficient level to be ultimately output + class CPlusPlusHandler(logging.Handler): def emit(self, record): if record.levelno <= logging.DEBUG: diff --git a/src/pybind/mgr/rest.py b/src/pybind/mgr/rest.py index b2efa36cf3c..44e6ed5c4e1 100644 --- a/src/pybind/mgr/rest.py +++ b/src/pybind/mgr/rest.py @@ -180,6 +180,10 @@ class Module(MgrModule): # class definition log = self.log + # Configure django.request logger + logging.getLogger("django.request").handlers = self.log.handlers + logging.getLogger("django.request").setLevel(logging.DEBUG) + class APIKeyAuthentication(authentication.BaseAuthentication): def authenticate(self, request): if not global_instance().enable_auth: