How to use the sap.cf_logging.core.constants.REQUEST_KEY function in sap

To help you get started, we’ve selected a few sap examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SAP / cf-python-logging-support / tests / test_falcon_logging.py View on Github external
def on_get(self, req, resp):
        self.extra.update({REQUEST_KEY: req})
        self.logger.log(logging.INFO, 'in route headers', extra=self.extra)
        assert check_log_record(self.stream, JOB_LOG_SCHEMA, self.expected) == {}

        resp.set_header('Content-Type', 'text/plain')
        resp.status = falcon.HTTP_200
        resp.body = 'ok'
github SAP / cf-python-logging-support / tests / django_logging / test_app / views.py View on Github external
def get(self, request, *args, **kwargs):
        """ Log a custom user message with the logger """
        expected = kwargs.get('expected') or {}
        extra = kwargs.get('extra') or {}
        if self.provide_request:
            extra.update({REQUEST_KEY: request})

        self.logger.log(logging.INFO, 'in route headers', extra=extra)
        assert check_log_record(self.stream, JOB_LOG_SCHEMA, expected) == {}
        return HttpResponse("ok", content_type='text/plain')
github SAP / cf-python-logging-support / tests / unit / test_init.py View on Github external
def test_init_cf_logger_simple_log():
    """ tests CfLogger creates SimpleLogRecord if extra is incomplete """
    assert isinstance(_make_record(extra={}), SimpleLogRecord)
    assert isinstance(_make_record(extra={REQUEST_KEY: {}}), SimpleLogRecord)
    assert isinstance(_make_record(extra={RESPONSE_KEY: {}}), SimpleLogRecord)
github SAP / cf-python-logging-support / sap / cf_logging / record / simple_log_record.py View on Github external
def __init__(self, extra, framework, *args, **kwargs):
        super(SimpleLogRecord, self).__init__(*args, **kwargs)

        utcnow = datetime.utcnow()
        self.written_at = util.iso_time_format(utcnow)
        self.written_ts = util.epoch_nano_second(utcnow)

        request = extra[REQUEST_KEY] if extra and REQUEST_KEY in extra else None

        self.correlation_id = framework.context.get_correlation_id(request) or defaults.UNKNOWN

        self.extra = dict((key, value) for key, value in extra.items()
                          if key not in _SKIP_ATTRIBUTES) if extra else {}
        for key, value in self.extra.items():
            setattr(self, key, value)
github SAP / cf-python-logging-support / sap / cf_logging / record / request_log_record.py View on Github external
def __init__(self, extra, framework, *args, **kwargs):

        super(RequestWebRecord, self).__init__(extra, framework, *args, **kwargs)

        context = framework.context
        request_reader = framework.request_reader
        response_reader = framework.response_reader

        request = extra[REQUEST_KEY]
        response = extra[RESPONSE_KEY]

        props = dict((key, value) for key, value in extra.items()
                     if key not in [RESPONSE_KEY, REQUEST_KEY])
        for key, value in props.items():
            setattr(self, key, value)

        length = request_reader.get_content_length(request)
        remote_ip = request_reader.get_remote_ip(request)

        self.type = 'request'
        self.direction = 'IN'
        self.remote_user = request_reader.get_remote_user(request)
        self.request = request_reader.get_path(request)
        self.referer = request_reader.get_http_header(
            request, 'referer', defaults.UNKNOWN)