How to use the sap.cf_logging.defaults 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 / sanic_logging / __init__.py View on Github external
def init(app, level=defaults.DEFAULT_LOGGING_LEVEL, custom_framework=None):
    """ Initializes logging in JSON format.

    Adds before and after request handlers to the `app` object to enable request info log.
    :param app: - Flask application object
    :param level: - valid log level from standard logging package (optional)
    :param custom_framework: - `Framework` instance - use in case you need
        to change request processing behaviour for example to customize context storage
    """
    if not isinstance(app, Sanic):
        raise TypeError('application should be instance of Sanic')

    framework = custom_framework or \
                Framework(
                    SANIC_FRAMEWORK_NAME,
                    SanicContext(),
                    SanicRequestReader(),
github SAP / cf-python-logging-support / sap / cf_logging / falcon_logging / __init__.py View on Github external
def init(app, level=defaults.DEFAULT_LOGGING_LEVEL, username_key='username'):
    """ Initializes logging in JSON format.

    :param app: - Falcon application object
    :param level: - valid log level from standard logging package (optional)
    :param username_key: key used by the framework to get the username
        out of the request user, set in the request context,
        like `request.context.get('user').get(key)`
    """
    if not isinstance(app, falcon.API):
        raise TypeError('application should be instance of Falcon API')

    framework = Framework(FALCON_FRAMEWORK_NAME, FalconContext(),
                          FalconRequestReader(username_key), FalconResponseReader())
    cf_logging.init(framework, level)
github SAP / cf-python-logging-support / sap / cf_logging / __init__.py View on Github external
def init(cfl_framework=None, level=defaults.DEFAULT_LOGGING_LEVEL):
    """ Initialize function. It sets up the logging library to output JSON
        formatted messages.

        Optional arguments framework to use and logging.level
    """
    global FRAMEWORK  # pylint: disable=global-statement
    global _SETUP_DONE  # pylint: disable=global-statement
    if _SETUP_DONE:
        raise RuntimeError('cf_logging already initialized')

    if cfl_framework is not None and not isinstance(cfl_framework, Framework):
        raise TypeError('expecting framework of type {}'.format(Framework.__name__))

    _SETUP_DONE = True
    FRAMEWORK = cfl_framework or JobFramework()
github SAP / cf-python-logging-support / sap / cf_logging / flask_logging / __init__.py View on Github external
def init(app, level=defaults.DEFAULT_LOGGING_LEVEL):
    """ Initializes logging in JSON format.

    Adds before and after request handlers to `app` object to enable request info log.
    :param app: - Flask application object
    :param level: - valid log level from standard logging package (optional)
    """
    if not isinstance(app, flask.Flask):
        raise TypeError('application should be instance of Flask')

    _init_framework(level)

    @app.before_request
    @before_request
    def _app_before_request():
        pass