Exception in 1.2.2 with custom log format
parente opened this issue · 4 comments
parente commented
First, thank you for creating json-logging-python. I wanted to share that the following code worked in 1.2.1 but raises an exception in 1.2.2.
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
)
json_logging.config_root_logger()
The tail of the exception (to remove names in paths) is the following:
...
File "/jobs/util.py", line 28, in init_logging
json_logging.config_root_logger()
File "/opt/conda/lib/python3.7/site-packages/json_logging/__init__.py", line 90, in config_root_logger
util.update_formatter_for_loggers([logging.root], _default_formatter)
File "/opt/conda/lib/python3.7/site-packages/json_logging/util.py", line 46, in update_formatter_for_loggers
if not isinstance(handler.formatter, formatter):
TypeError: isinstance() arg 2 must be a type or tuple of types
bobbui commented
thanks for reporting this, will take a look
bobbui commented
@parente could u please provide a more complete code snippet. I had trouble to reproduce the bug. Below seem working for me:
import logging
import sys
import json_logging
# log is initialized without a web framework name
json_logging.ENABLE_JSON_LOGGING = True
json_logging.init_non_web()
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
)
json_logging.config_root_logger()
logging.info("test log statement")
logging.info("test log statement with extra props", extra={'props': {"extra_property": 'extra_value'}})
bobbui commented
closed as no response from author, will reopen as needed