[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:
Stéphane Bidoul
2026-02-13 13:33:41 +01:00
committed by GitHub
co-authored by GitHub SilvioC2C
parent 627975b282
commit 083417f583
+10 -4
View File
@@ -6,17 +6,23 @@ import os
import threading
import uuid
import pythonjsonlogger
from odoo import http
from .strtobool import strtobool
_logger = logging.getLogger(__name__)
try:
from pythonjsonlogger import jsonlogger
except ImportError:
# Module ``jsonlogger`` of package ``python-json-logger`` is deprecated since version
# 3.1.0, keep it for backward compatibility
if hasattr(pythonjsonlogger, "json"):
jsonlogger = pythonjsonlogger.json
elif hasattr(pythonjsonlogger, "jsonlogger"):
jsonlogger = pythonjsonlogger.jsonlogger
else:
jsonlogger = None # noqa
_logger.debug("Cannot 'import pythonjsonlogger'.")
_logger.debug("Cannot import 'json' or 'jsonlogger' from 'pythonjsonlogger'.")
def is_true(strval):