def process_request(self, request): request_path = request.path req = RequestLog( requested_url=request.build_absolute_uri(request_path), datetime=datetime.now(), request_type=request.method, request_ip=request.META['REMOTE_ADDR'], ) req.save()
def process_request(self, request): try: logEntry = RequestLog( http_host = request.META.get('HTTP_HOST', ''), path_info = request.META['PATH_INFO'], remote_addr = request.META['REMOTE_ADDR'] ) logEntry.save() except DatabaseError: pass return None
def create_request_response_log(sender, **extra): r = RequestLog() r.request_url = request.base_url r.request_resource = request.path parameters = request.values.to_dict() r.request_oauth_parameters = {} for k in parameters.keys(): if k.startswith("oauth_"): r.request_oauth_parameters[k] = parameters.pop(k) r.request_parameters = parameters r.request_method = request.method r.put() g.request_log = r
def request_log(): requests = RequestLog.query().order(-RequestLog.created).fetch(25) return render_template("admin/request_log.html", requests=requests)
def process_exception(self, request, exception): extra = {} logging.error("An unhandled exception occurred: %s" % repr(exception), extra=extra) time_taken = -1 if hasattr(request, LOGGING_START_TIME_ATTR): start = getattr(request, LOGGING_START_TIME_ATTR) time_taken = time.time() - start records = self._handler.get_records() first = records[0] if len(records) > 0 else None records = [self._record_to_json(record, first) for record in records] message = json.dumps(records) log_entry = RequestLog(uri=request.path, message=message, duration=time_taken) log_entry.save()
def process_response(self, request, response): if not hasattr(request, LOGGING_ENABLE_ATTR): return response time_taken = -1 if hasattr(request, LOGGING_START_TIME_ATTR): start = getattr(request, LOGGING_START_TIME_ATTR) time_taken = time.time() - start records = self._handler.get_records() first = records[0] if len(records) > 0 else None records = [self._record_to_json(record, first) for record in records] message = json.dumps(records) log_entry = RequestLog(uri=request.path, message = message, duration=time_taken) log_entry.save() return response
def process_request(self, request): httprequest = RequestLog(date=datetime.now(), method=request.method, url=request.path, query_str=request.META.get("QUERY_STRING")) httprequest.save()
def process_request(self, request): rlog = RequestLog(method=request.method, \ url=request.get_full_path(), \ remote_addr=request.META.get('remote_addr', '')) rlog.save()