Skip to main content

Fluentd logger client for HTTP input

Project description

Fluent HTTP Python Logger Handler

A logger handler for fluentd logging collector.

How to use it

import logging
from fluent_http import FluentHttpHandler

logger = logging.getLogger(__name__)
fluent_http_handler = FluentHttpHandler(url='localhost', port=9880, tag='app.python')
logger.addHandler(fluent_http_handler)

# Test it!
logger.warning('Houston, we have a problem')

JSON logging

Install python-json-logger before

pip install python-json-logger
import logging
from pythonjsonlogger import jsonlogger
from fluent_http import FluentHttpHandler

logger = logging.getLogger(__name__)
fluent_http_handler = FluentHttpHandler(url='localhost', port=9880, tag='app.python')
fluent_http_handler.setFormatter(jsonlogger.JsonFormatter(timestamp=True))
logger.addHandler(fluent_http_handler)
logger.setLevel(logging.INFO)
# Test it!
logger.info('purchase done', extra={'item_id': 12345, 'quantity': 4, 'total_price': 32412})

Protected under Auth Basic HTTP

...
fluent_http_handler = FluentHttpHandler(url='https://fluent.example.com', port=443, tag='app.python', username='user', password='a_password')
...

License

MIT License

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

fluent-http-0.1.0.tar.gz (4.2 kB view hashes)

Uploaded Source

Built Distribution

fluent_http-0.1.0-py3-none-any.whl (4.3 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