mirror of
https://github.com/camptocamp/odoo-cloud-platform.git
synced 2026-06-24 02:08:36 +00:00
Change CI to GitHub actions
Use copier template from oca/oca-addons-repo-template Apply linting
This commit is contained in:
@@ -1,2 +1 @@
|
||||
|
||||
from . import json_log
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
# Copyright 2016-2021 Camptocamp SA
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
|
||||
|
||||
{"name": "JSON Logging",
|
||||
"version": "15.0.1.0.0",
|
||||
"author": "Camptocamp,Odoo Community Association (OCA)",
|
||||
"license": "AGPL-3",
|
||||
"category": "Extra Tools",
|
||||
"depends": ["base",
|
||||
],
|
||||
"external_dependencies": {
|
||||
"python": ["python-json-logger"],
|
||||
},
|
||||
"website": "http://www.camptocamp.com",
|
||||
"data": [],
|
||||
"installable": True,
|
||||
}
|
||||
{
|
||||
"name": "JSON Logging",
|
||||
"version": "15.0.1.0.0",
|
||||
"author": "Camptocamp,Odoo Community Association (OCA)",
|
||||
"license": "AGPL-3",
|
||||
"category": "Extra Tools",
|
||||
"depends": [
|
||||
"base",
|
||||
],
|
||||
"external_dependencies": {
|
||||
"python": ["python-json-logger"],
|
||||
},
|
||||
"website": "https://github.com/camptocamp/odoo-cloud-platform",
|
||||
"data": [],
|
||||
"installable": True,
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import logging
|
||||
import os
|
||||
import threading
|
||||
import uuid
|
||||
|
||||
from distutils.util import strtobool
|
||||
|
||||
from odoo import http
|
||||
@@ -20,23 +19,22 @@ except ImportError:
|
||||
|
||||
|
||||
def is_true(strval):
|
||||
return bool(strtobool(strval or '0'.lower()))
|
||||
return bool(strtobool(strval or "0".lower()))
|
||||
|
||||
|
||||
class OdooJsonFormatter(jsonlogger.JsonFormatter):
|
||||
|
||||
def add_fields(self, log_record, record, message_dict):
|
||||
record.pid = os.getpid()
|
||||
record.dbname = getattr(threading.currentThread(), 'dbname', '?')
|
||||
record.request_id = getattr(threading.current_thread(), 'request_uuid', None)
|
||||
record.uid = getattr(threading.current_thread(), 'uid', None)
|
||||
record.dbname = getattr(threading.currentThread(), "dbname", "?")
|
||||
record.request_id = getattr(threading.current_thread(), "request_uuid", None)
|
||||
record.uid = getattr(threading.current_thread(), "uid", None)
|
||||
_super = super(OdooJsonFormatter, self)
|
||||
return _super.add_fields(log_record, record, message_dict)
|
||||
|
||||
|
||||
if is_true(os.environ.get('ODOO_LOGGING_JSON')):
|
||||
if is_true(os.environ.get("ODOO_LOGGING_JSON")):
|
||||
formatted_message = (
|
||||
'%(asctime)s %(pid)s %(levelname)s %(dbname)s %(name)s: %(message)s'
|
||||
"%(asctime)s %(pid)s %(levelname)s %(dbname)s %(name)s: %(message)s"
|
||||
)
|
||||
formatter = OdooJsonFormatter(formatted_message)
|
||||
logging.getLogger().handlers[0].formatter = formatter
|
||||
|
||||
Reference in New Issue
Block a user