[Kimchi-devel] [PATCH] [Wok 2/3] Fix issue #140 - Add original exception to user request log message
Aline Manera
alinefm at linux.vnet.ibm.com
Mon Aug 22 16:52:38 UTC 2016
On 08/22/2016 01:21 PM, Lucio Correia wrote:
> On 22-08-2016 13:15, Aline Manera wrote:
>>
>>
>> On 08/22/2016 11:58 AM, Lucio Correia wrote:
>>> On 22-08-2016 11:13, Aline Manera wrote:
>>>>
>>>>
>>>> On 08/09/2016 04:15 PM, Lucio Correia wrote:
>>>>> Signed-off-by: Lucio Correia <luciojhc at linux.vnet.ibm.com>
>>>>> ---
>>>>> src/wok/control/base.py | 9 +++++++++
>>>>> src/wok/reqlogger.py | 34 +++++++++++++++++++++++++++++-----
>>>>> src/wok/root.py | 7 ++++++-
>>>>> 3 files changed, 44 insertions(+), 6 deletions(-)
>>>>>
>>>>> diff --git a/src/wok/control/base.py b/src/wok/control/base.py
>>>>> index f563aed..04cf2cb 100644
>>>>> --- a/src/wok/control/base.py
>>>>> +++ b/src/wok/control/base.py
>>>>> @@ -119,6 +119,7 @@ class Resource(object):
>>>>> def wrapper(*args, **kwargs):
>>>>> # status must be always set in order to request be
>>>>> logged.
>>>>> # use 500 as fallback for "exception not handled"
>>>>> cases.
>>>>> + details = None
>>>>> status = 500
>>>>>
>>>>> method = 'POST'
>>>>> @@ -149,6 +150,7 @@ class Resource(object):
>>>>> status = cherrypy.response.status
>>>>> return result
>>>>> except WokException, e:
>>>>
>>>>> + details = e
>>>>> status = e.getHttpStatusCode()
>>>>
>>>> 'details' and 'status' depends on which exception was raised.
>>>> I'd suggest to pass only the exception (which represents the 'details'
>>>> in this patch) to the RequestRecord() and let it work with the
>>>> exception.
>>>> That way we simplify the amount of parameters and IMO make it
>>>> easier to
>>>> work with.
>>>>
>>>
>>> Hi Aline, we also log successful requests (no exception).
>>>
>>> That's why status is informed separately.
>>>
>>
>> But you get the status code from the exception, right?
>>
>> status = e.getHttpStatusCode()
>>
>> So it seems always an exception exists there.
>
> No, there are some status = 200 for successful requests, which do not
> generate exceptions.
>
>
>
Oh Ok! I was seeing only the code in this patch.
More information about the Kimchi-devel
mailing list