Browse Source

[FIX] logging_json ImportError

pull/1542/head
Tom Blauwendraat 6 years ago
parent
commit
2835e11001
  1. 10
      logging_json/json_log.py

10
logging_json/json_log.py

@ -17,9 +17,9 @@ from openerp.netsvc import ColoredFormatter
_logger = logging.getLogger(__name__)
try:
from pythonjsonlogger import jsonlogger
from pythonjsonlogger.jsonlogger import JsonFormatter, RESERVED_ATTRS
except ImportError:
jsonlogger = None # noqa
JsonFormatter = object
_logger.debug("Cannot 'import pythonjsonlogger'.")
@ -55,7 +55,7 @@ REGEX = {
}
class OdooJsonFormatter(jsonlogger.JsonFormatter):
class OdooJsonFormatter(JsonFormatter):
def add_fields(self, log_record, record, message_dict):
record.pid = os.getpid()
@ -80,9 +80,9 @@ class OdooJsonDevFormatter(ColoredFormatter):
def format(self, record):
response = super(OdooJsonDevFormatter, self).format(record)
extra = {}
RESERVED_ATTRS = list(jsonlogger.RESERVED_ATTRS) + ["dbname", "pid"]
reserved_attrs = list(RESERVED_ATTRS) + ["dbname", "pid"]
for key, value in record.__dict__.items():
if (key not in RESERVED_ATTRS and not
if (key not in reserved_attrs and not
(hasattr(key, "startswith") and key.startswith('_'))):
extra[key] = value
if extra:

Loading…
Cancel
Save