Skip to content

TypeError: 'str' object is not callable #41

@mads79

Description

@mads79

In python 3 with configparser i get the following error when trying to log a message:

Traceback (most recent call last):
  File "/usr/lib/python3.5/logging/__init__.py", line 980, in emit
    msg = self.format(record)
  File "/usr/lib/python3.5/logging/__init__.py", line 830, in format
    return fmt.format(record)
  File "/home/mafm/pycharm-35venv/lib/python3.5/site-packages/logstash_formatter-0.5.15-py3.5.egg/logstash_formatter/__init__.py", line 172, in format
    return json.dumps(logr, default=self.json_default, cls=self.json_cls)
  File "/usr/lib/python3.5/json/__init__.py", line 237, in dumps
    **kw).encode(obj)
TypeError: 'str' object is not callable

It seems that _create_formatters in config.py of 'logging' will add a third argument (style) when initializing logstash formatter. This puts a string ("%") in stead of the json_cls.
Might be a new behaviour of "logging"?

Maybe the fix is as simple as changing the constructor function (init) to

def __init__(self,
                 fmt=None,
                 datefmt=None,
                 style=None,
                 json_cls=None,
                 json_default=_default_json_default):

?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions