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:
Alexandre Fayolle
2022-01-10 15:52:26 +01:00
committed by jcoux
co-authored by jcoux
parent 8424af433b
commit 6a6c75d7cb
+6 -2
View File
@@ -6,7 +6,7 @@ import time
from os import environ
from collections import MutableMapping
from contextlib import suppress
from werkzeug.exceptions import HTTPException
from odoo import models
from odoo.http import request as http_request
from odoo.tools.config import config
@@ -73,6 +73,10 @@ class IrHttp(models.AbstractModel):
@classmethod
def _monitoring_info(cls, request, response, begin, end):
if isinstance(response, HTTPException):
status_code = response.code
else:
status_code = response.status_code
info = {
# timing
"start_time": time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(begin)),
@@ -80,7 +84,7 @@ class IrHttp(models.AbstractModel):
# HTTP things
"method": request.httprequest.method,
"url": request.httprequest.url,
"status_code": response.status_code,
"status_code": status_code,
"headers": request.httprequest.environ.copy(),
# Odoo things
"uid": request.uid,