mirror of
https://github.com/camptocamp/odoo-cloud-platform.git
synced 2026-06-24 08:47:40 +00:00
[FIX] logging_json: forward compatibility (#510)
Make the module compatible w/ ``python-json-logger==3.3.*`` (importing ``jsonlogger`` displays a deprecation warning) Co-authored-by: SilvioC2C <87646954+SilvioC2C@users.noreply.github.com>
This commit is contained in:
co-authored by
GitHub
SilvioC2C
parent
627975b282
commit
083417f583
@@ -6,17 +6,23 @@ import os
|
|||||||
import threading
|
import threading
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
import pythonjsonlogger
|
||||||
|
|
||||||
from odoo import http
|
from odoo import http
|
||||||
|
|
||||||
from .strtobool import strtobool
|
from .strtobool import strtobool
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
try:
|
# Module ``jsonlogger`` of package ``python-json-logger`` is deprecated since version
|
||||||
from pythonjsonlogger import jsonlogger
|
# 3.1.0, keep it for backward compatibility
|
||||||
except ImportError:
|
if hasattr(pythonjsonlogger, "json"):
|
||||||
|
jsonlogger = pythonjsonlogger.json
|
||||||
|
elif hasattr(pythonjsonlogger, "jsonlogger"):
|
||||||
|
jsonlogger = pythonjsonlogger.jsonlogger
|
||||||
|
else:
|
||||||
jsonlogger = None # noqa
|
jsonlogger = None # noqa
|
||||||
_logger.debug("Cannot 'import pythonjsonlogger'.")
|
_logger.debug("Cannot import 'json' or 'jsonlogger' from 'pythonjsonlogger'.")
|
||||||
|
|
||||||
|
|
||||||
def is_true(strval):
|
def is_true(strval):
|
||||||
|
|||||||
Reference in New Issue
Block a user