Skip to content

StdlibFormatter has an incorrect constructor signature #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
zulrang opened this issue Aug 2, 2021 · 1 comment · Fixed by #54
Closed

StdlibFormatter has an incorrect constructor signature #53

zulrang opened this issue Aug 2, 2021 · 1 comment · Fixed by #54
Assignees

Comments

@zulrang
Copy link

zulrang commented Aug 2, 2021

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
@basepi
Copy link
Contributor

basepi commented Aug 10, 2021

Thanks for the report! Should be fixed in #54.

@basepi basepi self-assigned this Aug 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants