]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/mgr: fix django request logging
authorJohn Spray <john.spray@redhat.com>
Thu, 30 Jun 2016 23:28:16 +0000 (00:28 +0100)
committerJohn Spray <john.spray@redhat.com>
Thu, 29 Sep 2016 16:26:57 +0000 (17:26 +0100)
This was going to a text file, hook it in
to the proper logging.

Signed-off-by: John Spray <john.spray@redhat.com>
src/pybind/mgr/calamari_rest/settings.py
src/pybind/mgr/mgr_module.py
src/pybind/mgr/rest.py

index 4d555d59866fc4bbc250f16751483b00a757792c..7d60bdaeb249efc29900f070a42b8c60dd0f03b3 100644 (file)
@@ -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,
-        },
-    }
+
 }
 
 
index 2813e42793ec881390061b01c9db6f1c417ce001..d1e92a57a8b5dbdd23e49334b0d0ef9d59b795c5 100644 (file)
@@ -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:
index b2efa36cf3cd93fe27be52dab70c00b708baf7f1..44e6ed5c4e14bc2090c501d964e840687eca09b3 100644 (file)
@@ -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: