logging_json: fix RecursionError

Since Python 3.10, the use of 'threading.currentThread()' is deprecated
and generates a warning, and generating this warning log was in turn
entering in the `logging_json` mechanism, triggering an exception:

RecursionError: maximum recursion depth exceeded while calling a Python object
This commit is contained in:
Sébastien Alix
2024-03-27 13:19:22 +01:00
committed by cyrilmanuel
co-authored by cyrilmanuel
parent 99e6785179
commit f34dc6be27
+1 -1
View File
@@ -26,7 +26,7 @@ def is_true(strval):
class OdooJsonFormatter(jsonlogger.JsonFormatter): class OdooJsonFormatter(jsonlogger.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()
record.dbname = getattr(threading.currentThread(), "dbname", "?") record.dbname = getattr(threading.current_thread(), "dbname", "?")
record.request_id = getattr(threading.current_thread(), "request_uuid", None) record.request_id = getattr(threading.current_thread(), "request_uuid", None)
record.uid = getattr(threading.current_thread(), "uid", None) record.uid = getattr(threading.current_thread(), "uid", None)
_super = super(OdooJsonFormatter, self) _super = super(OdooJsonFormatter, self)