How to use the sap.cf_logging.FRAMEWORK.context.set_correlation_id 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_job_logging.py View on Github external
def test_set_correlation_id():
    """ Test setting correlation_id """
    correlation_id = '1234'
    cf_logging.init(level=logging.DEBUG)
    cf_logging.FRAMEWORK.context.set_correlation_id(correlation_id)

    logger, stream = config_logger('cli.test')
    logger.info('hi')

    log_json = JSONDecoder().decode(stream.getvalue())
    _, error = JsonValidator(JOB_LOG_SCHEMA).validate(log_json)

    assert error == {}
    assert log_json['correlation_id'] == correlation_id
    assert cf_logging.FRAMEWORK.context.get_correlation_id() == correlation_id
github SAP / cf-python-logging-support / tests / test_falcon_logging.py View on Github external
def test_logging_without_request():
    """ Test logger is usable in non request context """
    app = falcon.API()
    _set_up_falcon_logging(app)
    cf_logging.FRAMEWORK.context.set_correlation_id('value')

    logger, stream = config_logger('main.logger')
    logger.info('works')
    assert check_log_record(stream, JOB_LOG_SCHEMA, {'msg': v_str('works')}) == {}
github SAP / cf-python-logging-support / tests / test_job_logging.py View on Github external
def run(self):
            cf_logging.FRAMEWORK.context.set_correlation_id(self.correlation_id)
            time.sleep(0.1)
            self.read_correlation_id = cf_logging.FRAMEWORK.context.get_correlation_id()
github SAP / cf-python-logging-support / sap / cf_logging / sanic_logging / __init__.py View on Github external
def _wrapper(request):
        correlation_id = cf_logging.FRAMEWORK.request_reader.get_correlation_id(request)
        cf_logging.FRAMEWORK.context.set_correlation_id(correlation_id, request)
        cf_logging.FRAMEWORK.context.set('request_started_at', datetime.utcnow(), request)
        return wrapped(request)