Skip to main content

Log handler to send log via exchange.

Project description

exchange_log_handler

Log handler to send log via exchange

Dependencies

This library used ecederstrand/exchangelib to send exchange mail.

How to install:

pip install exchange_log_handler

Usage:

if __name__ == '__main__':
    import logging
    import logging.config
    logging.config.dictConfig({
        'version': 1,
        'disable_existing_loggers': False,
        'handlers': {
            'console': {
                'level': 'INFO',
                'class': 'logging.StreamHandler',
                'stream': 'ext://sys.stdout',
            },
            'email': {
                'level': 'ERROR',
                'class': 'exchange_log_handler.ExchangeHandler',
                'credentials': ('email_address', 'email_password'),
                'subject': lambda r: '{0}-{1}'.format(r.levelname, r.name),
                'toaddrs': 'recipient_email_address',
            },
        },
        'loggers': {
            '': {
                'handlers': [ 'console', 'email' ],
                'level': 'DEBUG',
                'propagate': True,
            },
        },
    })

    logger = logging.getLogger(__name__)
    try:
        raise ValueError('This is a test exception.')
    except Exception as e:
        logger.exception(e)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

exchange_log_handler-0.1.0.tar.gz (2.7 kB view hashes)

Uploaded Source

Built Distribution

exchange_log_handler-0.1.0-py3-none-any.whl (7.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page