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