Change CI to GitHub actions

Use copier template from oca/oca-addons-repo-template

Apply linting
This commit is contained in:
Yannick Payot
2023-05-24 19:44:34 +02:00
parent 1731912ba4
commit 5d2779d03b
77 changed files with 1698 additions and 865 deletions
-1
View File
@@ -1,2 +1 @@
from . import json_log
+16 -14
View File
@@ -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,
}
+6 -8
View File
@@ -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