def log_exception(self, exc_info, **kwargs): """Logs an exception The typical stack trace is often insufficient in determing the cause of errors so we add more details. """ exc_type, exc_value, _ = exc_info # Client disconnected errors must be suppressed here. if isinstance(exc_value, ClientDisconnected): return info = {'type': str(exc_type), 'message': str(exc_value.message)} # If we're handling a client disconnected error then we can't access # the requeset payload. if request: info['request'] = request.get_loggable_dict() for key, value in kwargs.items(): if hasattr(value, 'get_loggable_dict'): info[key] = value.get_loggable_dict() elif isinstance(value, (basestring, int)): info[key] = value self.logger.error({'exception': info}, exc_info=True)
def log_details(response): data = {'request': request.get_loggable_dict(), 'response': response.get_loggable_dict()} text = json.dumps(data) app.logger.info(json.dumps(data)) print text return response
def log_details(response): data = { 'request': request.get_loggable_dict(), 'response': response.get_loggable_dict() } text = json.dumps(data) app.logger.info(json.dumps(data)) print text return response
def log_info(self, **kwargs): """Logs INFO and includes the request. """ info = dict() if request: info['request'] = request.get_loggable_dict() for key, value in kwargs.items(): if hasattr(value, 'get_loggable_dict'): info[key] = value.get_loggable_dict() elif isinstance(value, (basestring, int)): info[key] = value self.logger.info(info)