def new_function(self, request, *args, **kwargs): """ Wrapped function """ # Log the call log_entry = Log() log_entry.source = 'API' log_entry.module = f.__module__ log_entry.method = f.__name__ log_entry.method_args = list(args) log_entry.method_kwargs = kwargs log_entry.time = time.time() log_entry.user = getattr(request, 'client').user if hasattr( request, 'client') else None log_entry.metadata = { 'meta': dict((str(key), str(value)) for key, value in request.META.iteritems()), 'request': dict((str(key), str(value)) for key, value in request.REQUEST.iteritems()), 'cookies': dict((str(key), str(value)) for key, value in request.COOKIES.iteritems()) } log_entry.save() # Call the function return f(self, request, *args, **kwargs)
def new_function(self, request, *args, **kwargs): """ Wrapped function """ # Log the call log_entry = Log() log_entry.source = 'API' log_entry.module = f.__module__ log_entry.method = f.__name__ log_entry.method_args = list(args) log_entry.method_kwargs = kwargs log_entry.time = time.time() log_entry.user = getattr(request, 'client').user if hasattr(request, 'client') else None log_entry.metadata = {'meta': dict((str(key), str(value)) for key, value in request.META.iteritems()), 'request': dict((str(key), str(value)) for key, value in request.REQUEST.iteritems()), 'cookies': dict((str(key), str(value)) for key, value in request.COOKIES.iteritems())} log_entry.save() # Call the function return f(self, request, *args, **kwargs)
def new_function(*args, **kwargs): """ Wrapped function """ # Log the call log_entry = Log() log_entry.source = event_type log_entry.module = f.__module__ log_entry.method = f.__name__ log_entry.method_args = list(args) log_entry.method_kwargs = kwargs log_entry.time = time.time() if event_type == 'VOLUMEDRIVER_TASK': try: log_entry.storagedriver = StorageDriverList.get_by_storagedriver_id(kwargs['storagedriver_id']) log_entry.save() except ObjectNotFoundException: pass else: log_entry.save() # Call the function return f(*args, **kwargs)