mirror of
https://github.com/camptocamp/odoo-cloud-platform.git
synced 2026-06-24 02:08:36 +00:00
monitoring_log_requests
in case the response is an HTTPException, logging would generate a crash because of wrong attribute name
This commit is contained in:
@@ -6,7 +6,7 @@ import time
|
|||||||
from os import environ
|
from os import environ
|
||||||
from collections import MutableMapping
|
from collections import MutableMapping
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
|
from werkzeug.exceptions import HTTPException
|
||||||
from odoo import models
|
from odoo import models
|
||||||
from odoo.http import request as http_request
|
from odoo.http import request as http_request
|
||||||
from odoo.tools.config import config
|
from odoo.tools.config import config
|
||||||
@@ -73,6 +73,10 @@ class IrHttp(models.AbstractModel):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _monitoring_info(cls, request, response, begin, end):
|
def _monitoring_info(cls, request, response, begin, end):
|
||||||
|
if isinstance(response, HTTPException):
|
||||||
|
status_code = response.code
|
||||||
|
else:
|
||||||
|
status_code = response.status_code
|
||||||
info = {
|
info = {
|
||||||
# timing
|
# timing
|
||||||
"start_time": time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(begin)),
|
"start_time": time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(begin)),
|
||||||
@@ -80,7 +84,7 @@ class IrHttp(models.AbstractModel):
|
|||||||
# HTTP things
|
# HTTP things
|
||||||
"method": request.httprequest.method,
|
"method": request.httprequest.method,
|
||||||
"url": request.httprequest.url,
|
"url": request.httprequest.url,
|
||||||
"status_code": response.status_code,
|
"status_code": status_code,
|
||||||
"headers": request.httprequest.environ.copy(),
|
"headers": request.httprequest.environ.copy(),
|
||||||
# Odoo things
|
# Odoo things
|
||||||
"uid": request.uid,
|
"uid": request.uid,
|
||||||
|
|||||||
Reference in New Issue
Block a user