]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
Merge pull request #30961 from rjfd/wip-mgr-module-logging
authorLaura Paduano <lpaduano@suse.com>
Tue, 3 Dec 2019 09:29:42 +0000 (10:29 +0100)
committerGitHub <noreply@github.com>
Tue, 3 Dec 2019 09:29:42 +0000 (10:29 +0100)
mgr: module logging infrastructure

Reviewed-by: Ernesto Puertat <epuertat@redhat.com>
Reviewed-by: Ricardo Marques <rimarques@suse.com>
Reviewed-by: Laura Paduano <lpaduano@suse.com>
1  2 
src/mgr/ActivePyModule.cc
src/mgr/PyModule.cc
src/mgr/PyModuleRunner.cc
src/mgr/PyModuleRunner.h
src/pybind/mgr/dashboard/__init__.py
src/pybind/mgr/dashboard/controllers/__init__.py
src/pybind/mgr/dashboard/controllers/home.py
src/pybind/mgr/dashboard/grafana.py
src/pybind/mgr/dashboard/services/orchestrator.py
src/pybind/mgr/dashboard/tests/__init__.py

index 852c17be81dc9672f0ecf7181ec5d2806a72d42c,bc70560ffa7af2ce5e48c38778970ff9b652d178..78704f8769123665ce6acf88235e34eb15c0fac8
@@@ -169,16 -159,11 +169,16 @@@ PyObject *ActivePyModule::dispatch_remo
  
  void ActivePyModule::config_notify()
  {
 +  if (is_dead()) {
 +    dout(5) << "cancelling config_notify" << dendl;
 +    return;
 +  }
 +
    Gil gil(py_module->pMyThreadState, true);
-   dout(20) << "Calling " << py_module->get_name() << ".config_notify..."
+   dout(20) << "Calling " << py_module->get_name() << "._config_notify..."
           << dendl;
    auto remoteResult = PyObject_CallMethod(pClassInstance,
-                                         const_cast<char*>("config_notify"),
+                                         const_cast<char*>("_config_notify"),
                                          (char*)NULL);
    if (remoteResult != nullptr) {
      Py_DECREF(remoteResult);
Simple merge
index cde54f215543e981f93a685dd81a095817dba5f1,dbddfd411eef3a089277d64d91b9d942d35aac60..c5408bd9da2761b980c72094aa44f3c07778481c
@@@ -88,15 -88,13 +88,15 @@@ void PyModuleRunner::shutdown(
      derr << "Failed to invoke shutdown() on " << get_name() << dendl;
      derr << handle_pyerror() << dendl;
    }
 +
 +  dead = true;
  }
  
- void PyModuleRunner::log(int level, const std::string &record)
+ void PyModuleRunner::log(const std::string &record)
  {
  #undef dout_prefix
- #define dout_prefix *_dout << "mgr[" << get_name() << "] "
-   dout(ceph::dout::need_dynamic(level)) << record << dendl;
+ #define dout_prefix *_dout
+   dout(0) << record << dendl;
  #undef dout_prefix
  #define dout_prefix *_dout << "mgr " << __func__ << " "
  }
Simple merge
Simple merge
index 0cb6128af440ae37205912f5dcf2b3e85140c9aa,348eed9ad2b3e5251f4b7fa750ec5e92fd75b3a5..114f4b503cf1c65cff869a97807437440a3e9fb6
@@@ -586,9 -587,9 +587,10 @@@ class BaseController(object)
                                                   self.action)
  
      def __init__(self):
+         logger = logging.getLogger('controller')
          logger.info('Initializing controller: %s -> %s',
                      self.__class__.__name__, self._cp_path_)
 +        super(BaseController, self).__init__()
  
      def _has_permissions(self, permissions, scope=None):
          if not self._cp_config['tools.authenticate.on']:
index c835b0f7b0d0605fb5eb1196c6a7811e8fb97104,2b05eaee02678de654d876683e09d46d0d6a4a5c..3abbcd710d8b4aa9bb562809a1c2d0d1652d58dc
@@@ -13,37 -14,31 +14,40 @@@ import cherryp
  from cherrypy.lib.static import serve_file
  
  from . import Controller, UiApiController, BaseController, Proxy, Endpoint
- from .. import mgr, logger
+ from .. import mgr
+ logger = logging.getLogger("controllers.home")
  
  
 -LANGUAGES = {f for f in os.listdir(mgr.get_frontend_path())
 -             if os.path.isdir(os.path.join(mgr.get_frontend_path(), f))}
 -LANGUAGES_PATH_MAP = {f.lower(): {'lang': f, 'path': os.path.join(mgr.get_frontend_path(), f)}
 -                      for f in LANGUAGES}
 -# pre-populating with the primary language subtag
 -for _lang in list(LANGUAGES_PATH_MAP.keys()):
 -    if '-' in _lang:
 -        LANGUAGES_PATH_MAP[_lang.split('-')[0]] = {
 -            'lang': LANGUAGES_PATH_MAP[_lang]['lang'], 'path': LANGUAGES_PATH_MAP[_lang]['path']}
 -
 -
 -def _get_default_language():
 -    with open("{}/../package.json".format(mgr.get_frontend_path()), "r") as f:
 -        config = json.load(f)
 -    return config['config']['locale']
 -
 -
 -DEFAULT_LANGUAGE = _get_default_language()
 -DEFAULT_LANGUAGE_PATH = os.path.join(mgr.get_frontend_path(), DEFAULT_LANGUAGE)
 +class LanguageMixin(object):
 +    def __init__(self):
 +        self.LANGUAGES = {
 +            f
 +            for f in os.listdir(mgr.get_frontend_path())
 +            if os.path.isdir(os.path.join(mgr.get_frontend_path(), f))
 +        }
 +        self.LANGUAGES_PATH_MAP = {
 +            f.lower(): {
 +                'lang': f,
 +                'path': os.path.join(mgr.get_frontend_path(), f)
 +            }
 +            for f in self.LANGUAGES
 +        }
 +        # pre-populating with the primary language subtag.
 +        for lang in list(self.LANGUAGES_PATH_MAP.keys()):
 +            if '-' in lang:
 +                self.LANGUAGES_PATH_MAP[lang.split('-')[0]] = {
 +                    'lang': self.LANGUAGES_PATH_MAP[lang]['lang'],
 +                    'path': self.LANGUAGES_PATH_MAP[lang]['path']
 +                }
 +        with open("{}/../package.json".format(mgr.get_frontend_path()),
 +                  "r") as f:
 +            config = json.load(f)
 +        self.DEFAULT_LANGUAGE = config['config']['locale']
 +        self.DEFAULT_LANGUAGE_PATH = os.path.join(mgr.get_frontend_path(),
 +                                                  self.DEFAULT_LANGUAGE)
 +        super(LanguageMixin, self).__init__()
  
  
  @Controller("/", secure=False)
Simple merge
index 4d60b3f4a4e5a213da323305cd4411e7bc841ac3,17bbc600bd831916c0d0c0f1ffd84360107b36a6..421378a155d80633dbb44e8cb3fc2322fa904203
@@@ -3,8 -3,8 +3,9 @@@
  from __future__ import absolute_import
  
  import json
+ import logging
  import threading
 +import sys
  import time
  
  import cherrypy