Skip to content

Commit 85617b1

Browse files
rootmambelli
authored andcommitted
fix source logging by defining logger in Sources correctly
1 parent 669555c commit 85617b1

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

src/decisionengine/framework/engine/SourceWorkers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,20 @@ def __init__(self, key, config, logger_config, channel_name, exchange, broker_ur
5050
:arg config: configuration dictionary describing the worker
5151
"""
5252
super().__init__(name=f"SourceWorker-{key}")
53-
self.module_instance = _create_module_instance(config, Source, channel_name)
5453
self.config = config
5554
self.logger_config = logger_config
5655
self.channel_name = channel_name
5756
self.module = self.config["module"]
5857
self.key = key
59-
self.class_name = self.module_instance.__class__.__name__
6058
SOURCE_ACQUIRE_GAUGE.labels(self.key)
6159

6260
self.loglevel = multiprocessing.Value("i", logging.WARNING)
6361
self.logger = structlog.getLogger(logconf.SOURCELOGGERNAME)
6462
self.logger.setLevel(logging.DEBUG)
6563

64+
self.module_instance = _create_module_instance(config, Source, channel_name)
65+
self.class_name = self.module_instance.__class__.__name__
66+
6667
logger = structlog.getLogger(logconf.LOGGERNAME)
6768
logger = logger.bind(module=__name__.split(".")[-1], source=self.key)
6869

src/decisionengine/framework/modules/Source.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
import pprint
55
import sys
66

7+
import structlog
8+
9+
import decisionengine.framework.modules.logging_configDict as logconf
10+
711
from decisionengine.framework.config.ValidConfig import ValidConfig
812
from decisionengine.framework.modules import describe as _describe
913
from decisionengine.framework.modules.describe import Parameter, supports_config
@@ -18,6 +22,8 @@ class Source(Module):
1822
def __init__(self, set_of_parameters):
1923
super().__init__(set_of_parameters)
2024

25+
self.logger = structlog.getLogger(logconf.SOURCELOGGERNAME)
26+
2127
# acquire: The action function for a source. Will
2228
# retrieve data from external sources and issue a
2329
# DataBlock "put" transaction.

0 commit comments

Comments
 (0)