yalp.inputs.log_handlerΒΆ

The log handler inputer is for use within Python’s logging facility. Therefore it uses a different configuration method than normal YALP plugins. Instead of using the YALP YAML configuration file, this inputer is configured in another project’s python logging configuration.

For example, in another Python project:

LOGGING = {
    'version': 1,
    'disabled_existing_loggers': False,
    'handlers': {
        'yalp': {
            'level': 'INFO',
            'class': 'yalp.inputs.log_handler.YalpHandler',
            'type': 'my_package_logs',
            'pipeline': {
                'broker_url': 'amqp://guest@guest@localhost:5672//',
            },
        },
    },
    'loggers': {
        'my_package': {
            'handlers': ['yalp']
            'level': 'INFO',
        },
    }
}

The handler accepts the following optional fields:

type
The type of the event for the parsers/outputers to filter on.
pipeline

A dictionary of YALP configuration settings. The pipeline option accepts the following fields:

parsers
Boolean option. If true events will be sent to the parsers, otherwise they will be sent directly to the outputers. Default is False.

Additionaly, pipeline option for the handler accepts all of the YALP Celery Configuration settings, such as the broker_url, with the same defaults.

Then in the Python project, send a log message as follows:

logger.info('a log message', extra={'additional': 'data will be included'})

This will create an event like:

{
    'time_stamp': '2015-01-01T01:00:00',
    'message': 'a log message',
    'additional': 'data will be included',
    'logger': 'my_pacakge.my_module',
    'funcName': 'func_with_log',
    'levelname': 'INFO',
    'levelno': 20,
    'hostname': 'my_host',
}