betcode-org/flumine

KeyError in BaseStrategy when 'extra' in logging overrides default field 'name'

poklius opened this issue · 0 comments

When passed to logger extra parameters overwrite default logging fields like name

class Sample(BaseStrategy):
    def start(self) -> None:
        logger.info("Starting strategy Sample", extra=self.info)

self.info has item {"name": self.name} so it raises KeyError

KeyError: "Attempt to overwrite 'name' in LogRecord"

from python-json-logger

RESERVED_ATTRS = (
    'args', 'asctime', 'created', 'exc_info', 'exc_text', 'filename',
    'funcName', 'levelname', 'levelno', 'lineno', 'module',
    'msecs', 'message', 'msg', 'name', 'pathname', 'process',
    'processName', 'relativeCreated', 'stack_info', 'thread', 'threadName')