Beispiel #1
0
    def process_exception(self, request, exception):
        extra = {'mac': '', 'type': ''}
        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 = cjson.encode(records)

        log_entry = RequestLog(uri=request.path,
                               message=message,
                               duration=time_taken)
        log_entry.save()
Beispiel #2
0
    def process_exception(self, request, exception):
        extra = {'mac':'', 'type':''}
        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 = cjson.encode(records)

        log_entry = RequestLog(uri=request.path,
                              message=message,
                              duration=time_taken)
        log_entry.save()
Beispiel #3
0
    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 = cjson.encode(records)

        log_entry = RequestLog(uri=request.path,
                               message=message,
                               duration=time_taken)
        log_entry.save()

        return response
Beispiel #4
0
    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 = cjson.encode(records)

        log_entry = RequestLog(uri=request.path,
                              message = message,
                              duration=time_taken)
        log_entry.save()

        return response