Skip to content

StdlibFormatter has an incorrect constructor signature #53

Closed
@zulrang

Description

@zulrang

StdlibFormatter inherits from logging.Formatter, but has a completely different constructor signature, making it incompatible with anything that takes the formatter class name.

StdlibFormatter signature: def __init__(self, stack_trace_limit=None, exclude_fields=()):
logging.Formatter signature: def __init__(self, fmt=None, datefmt=None, style='%', validate=True):

Any time you pass "ecs_logging.StdlibFormatter" where a library takes a class name for a log formatter (Django, Gunicorn, etc.), it fails with the following error:

  File "/usr/local/lib/python3.8/logging/config.py", line 71, in fileConfig
    formatters = _create_formatters(cp)
  File "/usr/local/lib/python3.8/logging/config.py", line 119, in _create_formatters
    f = c(fs, dfs, stl)
TypeError: __init__() takes from 1 to 3 positional arguments but 4 were given

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions