def _logging(original):
 @wraps(original)
 def logger(self, request, **routeArguments):
  logger = _get_logger(self)
  action = REQUEST(logger, request_path=request.path, method=request.method)
  incidentIdentifier = action.serialize_task_id()
  with action.context():
   d = DeferredContext(original(self, request, **routeArguments))
  def failure(reason):
   if reason.check(BadRequest):
    code = reason.value.code
    result = reason.value.result
   else:
    writeFailure(reason, logger, LOG_SYSTEM)
    code = INTERNAL_SERVER_ERROR
    result = incidentIdentifier
   request.setResponseCode(code)
   request.responseHeaders.setRawHeaders('content-type', ['application/json'])
   return dumps(result)
  d.addErrback(failure)
  d.addActionFinish()
  return d.result
 return logger

def _logging ( original ) : @ wraps ( original ) def logger ( self , request , ** routeArguments ) : logger = _get_logger ( self ) action = REQUEST ( logger , request_path = request . path , method = request . method ) incidentIdentifier = action . serialize_task_id ( ) with action . context ( ) : d = DeferredContext ( original ( self , request , ** routeArguments ) ) def failure ( reason ) : if reason . check ( BadRequest ) : code = reason . value . code result = reason . value . result else : writeFailure ( reason , logger , LOG_SYSTEM ) code = INTERNAL_SERVER_ERROR result = incidentIdentifier request . setResponseCode ( code ) request . responseHeaders . setRawHeaders ( 'content-type' , [ 'application/json' ] ) return dumps ( result ) d . addErrback ( failure ) d . addActionFinish ( ) return d . result return logger
decorate a method which implements an api endpoint to add eliot-based logging .