From: Laura Paduano Date: Tue, 3 Dec 2019 09:29:42 +0000 (+0100) Subject: Merge pull request #30961 from rjfd/wip-mgr-module-logging X-Git-Tag: v15.1.0~694 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4ad8591fe4adfe89708b10a2e2e3022b2bc75677;p=ceph.git Merge pull request #30961 from rjfd/wip-mgr-module-logging mgr: module logging infrastructure Reviewed-by: Ernesto Puertat Reviewed-by: Ricardo Marques Reviewed-by: Laura Paduano --- 4ad8591fe4adfe89708b10a2e2e3022b2bc75677 diff --cc src/mgr/ActivePyModule.cc index 852c17be81dc,bc70560ffa7a..78704f876912 --- a/src/mgr/ActivePyModule.cc +++ b/src/mgr/ActivePyModule.cc @@@ -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("config_notify"), + const_cast("_config_notify"), (char*)NULL); if (remoteResult != nullptr) { Py_DECREF(remoteResult); diff --cc src/mgr/PyModuleRunner.cc index cde54f215543,dbddfd411eef..c5408bd9da27 --- a/src/mgr/PyModuleRunner.cc +++ b/src/mgr/PyModuleRunner.cc @@@ -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__ << " " } diff --cc src/pybind/mgr/dashboard/controllers/__init__.py index 0cb6128af440,348eed9ad2b3..114f4b503cf1 --- a/src/pybind/mgr/dashboard/controllers/__init__.py +++ b/src/pybind/mgr/dashboard/controllers/__init__.py @@@ -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']: diff --cc src/pybind/mgr/dashboard/controllers/home.py index c835b0f7b0d0,2b05eaee0267..3abbcd710d8b --- a/src/pybind/mgr/dashboard/controllers/home.py +++ b/src/pybind/mgr/dashboard/controllers/home.py @@@ -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) diff --cc src/pybind/mgr/dashboard/tests/__init__.py index 4d60b3f4a4e5,17bbc600bd83..421378a155d8 --- a/src/pybind/mgr/dashboard/tests/__init__.py +++ b/src/pybind/mgr/dashboard/tests/__init__.py @@@ -3,8 -3,8 +3,9 @@@ from __future__ import absolute_import import json + import logging import threading +import sys import time import cherrypy