Skip to content

Commit

Permalink
fix source logging by defining logger in Sources correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
root authored and mambelli committed Dec 15, 2022
1 parent 669555c commit 85617b1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/decisionengine/framework/engine/SourceWorkers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 6 additions & 0 deletions src/decisionengine/framework/modules/Source.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down

0 comments on commit 85617b1

Please sign in to comment.