From 85617b14dc0639a4d98503633bda3a3b9dc5296f Mon Sep 17 00:00:00 2001 From: root Date: Fri, 28 Oct 2022 16:24:09 +0000 Subject: [PATCH] fix source logging by defining logger in Sources correctly --- src/decisionengine/framework/engine/SourceWorkers.py | 5 +++-- src/decisionengine/framework/modules/Source.py | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/decisionengine/framework/engine/SourceWorkers.py b/src/decisionengine/framework/engine/SourceWorkers.py index 91cd7a2a5..f1e619f64 100644 --- a/src/decisionengine/framework/engine/SourceWorkers.py +++ b/src/decisionengine/framework/engine/SourceWorkers.py @@ -50,19 +50,20 @@ def __init__(self, key, config, logger_config, channel_name, exchange, broker_ur :arg config: configuration dictionary describing the worker """ super().__init__(name=f"SourceWorker-{key}") - self.module_instance = _create_module_instance(config, Source, channel_name) self.config = config self.logger_config = logger_config self.channel_name = channel_name self.module = self.config["module"] self.key = key - self.class_name = self.module_instance.__class__.__name__ SOURCE_ACQUIRE_GAUGE.labels(self.key) self.loglevel = multiprocessing.Value("i", logging.WARNING) self.logger = structlog.getLogger(logconf.SOURCELOGGERNAME) self.logger.setLevel(logging.DEBUG) + self.module_instance = _create_module_instance(config, Source, channel_name) + self.class_name = self.module_instance.__class__.__name__ + logger = structlog.getLogger(logconf.LOGGERNAME) logger = logger.bind(module=__name__.split(".")[-1], source=self.key) diff --git a/src/decisionengine/framework/modules/Source.py b/src/decisionengine/framework/modules/Source.py index c054268bc..a4360e062 100644 --- a/src/decisionengine/framework/modules/Source.py +++ b/src/decisionengine/framework/modules/Source.py @@ -4,6 +4,10 @@ import pprint import sys +import structlog + +import decisionengine.framework.modules.logging_configDict as logconf + from decisionengine.framework.config.ValidConfig import ValidConfig from decisionengine.framework.modules import describe as _describe from decisionengine.framework.modules.describe import Parameter, supports_config @@ -18,6 +22,8 @@ class Source(Module): def __init__(self, set_of_parameters): super().__init__(set_of_parameters) + self.logger = structlog.getLogger(logconf.SOURCELOGGERNAME) + # acquire: The action function for a source. Will # retrieve data from external sources and issue a # DataBlock "put" transaction.