Exemplo n.º 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()
Exemplo n.º 2
0
    def process_exception(self, request, exception):
    # TODO(winkler) document
        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()
Exemplo n.º 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
Exemplo n.º 4
0
    def process_response(self, request, response):
    # TODO(winkler) document
        
        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