def timing_stats(**dec_kwargs):
 def decorating_func(func):
  method = func.__name__
  @functools.wraps(func)
  def _timing_stats(ctrl, *args, **kwargs):
   start_time = time.time()
   resp = func(ctrl, *args, **kwargs)
   if server_handled_successfully(resp.status_int):
    ctrl.logger.timing_since((method + '.timing'), start_time, **dec_kwargs)
   else:
    ctrl.logger.timing_since((method + '.errors.timing'), start_time, **dec_kwargs)
   return resp
  return _timing_stats
 return decorating_func

def timing_stats ( ** dec_kwargs ) : def decorating_func ( func ) : method = func . __name__ @ functools . wraps ( func ) def _timing_stats ( ctrl , * args , ** kwargs ) : start_time = time . time ( ) resp = func ( ctrl , * args , ** kwargs ) if server_handled_successfully ( resp . status_int ) : ctrl . logger . timing_since ( ( method + '.timing' ) , start_time , ** dec_kwargs ) else : ctrl . logger . timing_since ( ( method + '.errors.timing' ) , start_time , ** dec_kwargs ) return resp return _timing_stats return decorating_func
returns a decorator that logs timing events or errors for public methods in swifts wsgi server controllers .