I am trying to register an error in a decorator function using app.logger.error('') , but that just doesn't work. In addition, I cannot debug this situation, and I can only see the response from the http client:
(I use nginx + uwsgi + flask)
HTTP / 1.1 502 Bad Gateway
Server: nginx
Date: Sun, Aug 12 2012 15:45:09 GMT
Content-Type: text / html
Content-Length: 14
Connection: keep-alive
Everything works fine with the line: app.logger.error('panic !!!')
def mydecorator(): def decorator(f): def wrapped_function(*args, **kwargs): try: ip = Mytable.query.filter_by(ip=request.remote_addr).first() except: app.logger.error('panic !!!') else: dootherthing() resp = make_response(f(*args, **kwargs)) h = resp.headers h['add-this-header'] = ":)" return resp return update_wrapper(wrapped_function, f) return decorator
It seems to be out of context or something like that.
Alvarolm
source share