示例#1
0
 def wrapped_func(*args, **kwargs):
     # wrap everything besides the function call in a try/except
     # block.  we don't ever want the logging to prevent the 
     # basic view functionality from working. 
     try:
         # attempt to find the request object from all the argument
         # values, checking first the args and then the kwargs 
         req = None
         for arg in args:
             if _is_http_request(arg):
                 req = arg
                 break
         if not req:
             for arg in kwargs.values():
                 if _is_http_request(arg):
                     req = arg
                     break
         if req:
             log = RequestLog.from_request(arg)
             log.save()
         else: 
             logging.error("No request argument found for %s, information will not be logged." %
                            f.func_name)
     except Exception, e:
         logging.error("Error logging request!  The error is: %s." % e)
示例#2
0
def _log_build_download(request, build, type):
    '''Logs and saves a build download.'''
    log = RequestLog.from_request(request)
    log.save()
    download = BuildDownload(type=type, build=build, log=log)
    download.save()
    # Also add a little notifier here so we can track build downloads
    if (hasattr(request, "user")):
        user_display = str(request.user)
    else:
        user_display = "An anonymous user"
    logging.error("Hey! %s just downloaded the %s file for build %s!  The request was a %s"\
                   %(user_display, type, build.get_display_string(), log))
示例#3
0
文件: views.py 项目: aquaya/wqmanager
def _log_build_upload(request, build):
    """Logs and saves a build upload."""
    log = RequestLog.from_request(request)
    log.save()
    upload = BuildUpload(build=build, log=log)
    upload.save()