mirror of
https://github.com/searxng/searxng
synced 2024-11-05 06:01:05 +00:00
Merge pull request #305 from dalf/fix-engine-logger
[fix] logger per engine: make .logger is always initialized
This commit is contained in:
commit
97acedd9fe
@ -110,10 +110,26 @@ def load_engine(engine_data):
|
||||
if is_missing_required_attributes(engine):
|
||||
return None
|
||||
|
||||
engine.logger = logger.getChild(engine_name)
|
||||
set_loggers(engine, engine_name)
|
||||
|
||||
return engine
|
||||
|
||||
|
||||
def set_loggers(engine, engine_name):
|
||||
# set the logger for engine
|
||||
engine.logger = logger.getChild(engine_name)
|
||||
# the engine may have load some other engines
|
||||
# may sure the logger is initialized
|
||||
for module_name, module in sys.modules.items():
|
||||
if (
|
||||
module_name.startswith("searx.engines")
|
||||
and module_name != "searx.engines.__init__"
|
||||
and not hasattr(module, "logger")
|
||||
):
|
||||
module_engine_name = module_name.split(".")[-1]
|
||||
module.logger = logger.getChild(module_engine_name)
|
||||
|
||||
|
||||
def update_engine_attributes(engine, engine_data):
|
||||
# set engine attributes from engine_data
|
||||
for param_name, param_value in engine_data.items():
|
||||
|
@ -438,8 +438,3 @@ def get_key_label(key_name, lang):
|
||||
if labels is None:
|
||||
return None
|
||||
return get_label(labels, lang)
|
||||
|
||||
|
||||
def init(_):
|
||||
import searx.engines.wikidata # pylint: disable=import-outside-toplevel
|
||||
searx.engines.wikidata.logger = logger
|
||||
|
Loading…
Reference in New Issue
Block a user