How to use the sap.cf_logging.defaults.UNKNOWN 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 / sap / cf_logging / record / application_info.py View on Github external
""" Module for record constants """
import os

from sap.cf_logging import defaults
from sap.cf_logging.record import util


LAYER = 'python'
COMPONENT_ID = util.get_vcap_param('application_id', defaults.UNKNOWN)
COMPONENT_NAME = util.get_vcap_param('name', defaults.UNKNOWN)
COMPONENT_INSTANCE = os.getenv('CF_INSTANCE_INDEX', 0)
SPACE_ID = util.get_vcap_param('space_id', defaults.UNKNOWN)
SPACE_NAME = util.get_vcap_param('space_name', defaults.UNKNOWN)
CONTAINER_ID = os.getenv('CF_INSTANCE_IP', defaults.UNKNOWN)
COMPONENT_TYPE = 'application'
github SAP / cf-python-logging-support / sap / cf_logging / flask_logging / request_reader.py View on Github external
def get_remote_user(self, request):
        if request.authorization is not None:
            return request.authorization.username

        return defaults.UNKNOWN
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
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)
        self.x_forwarded_for = request_reader.get_http_header(
            request, 'x-forwarded-for', defaults.UNKNOWN)
        self.protocol = request_reader.get_protocol(request)
        self.method = request_reader.get_method(request)
        self.remote_ip = remote_ip
        self.request_size_b = util.parse_int(length, -1)
        self.remote_host = remote_ip
        self.remote_port = request_reader.get_remote_port(
            request) or defaults.UNKNOWN

        request_start = context.get(
            'request_started_at', request) or defaults.UNIX_EPOCH
        self.request_received_at = util.iso_time_format(request_start)

        # response related
        response_sent_at = context.get(
            'response_sent_at', request) or defaults.UNIX_EPOCH
        self.response_sent_at = util.iso_time_format(response_sent_at)
        self.response_time_ms = util.time_delta_ms(
            request_start, response_sent_at)

        self.response_status = util.parse_int(
            response_reader.get_status_code(response), defaults.STATUS)
        self.response_size_b = util.parse_int(
            response_reader.get_response_size(response), defaults.RESPONSE_SIZE_B)
github SAP / cf-python-logging-support / sap / cf_logging / record / request_log_record.py View on Github external
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)
        self.x_forwarded_for = request_reader.get_http_header(
            request, 'x-forwarded-for', defaults.UNKNOWN)
        self.protocol = request_reader.get_protocol(request)
        self.method = request_reader.get_method(request)
        self.remote_ip = remote_ip
        self.request_size_b = util.parse_int(length, -1)
        self.remote_host = remote_ip
        self.remote_port = request_reader.get_remote_port(
            request) or defaults.UNKNOWN

        request_start = context.get(
            'request_started_at', request) or defaults.UNIX_EPOCH
        self.request_received_at = util.iso_time_format(request_start)

        # response related
        response_sent_at = context.get(