Configure LDP logging handlers and middleware for your Flask app.
Project description
Flask-LDP
Work in progres ...
Fork of https://github.com/gridscale/flask-graylog2 to support OVH Logs Data Platform.
Which is himself a fork of github.com/underdogio/flask-graylog with additional patches and features.
This is a Flask extension that allows you to configure a OVH Logs Data Platform (LDP) logging handler as well as some middleware to log every request/response pair to Graylog.
See also:
Installation
You can install it with pip
:
$ pip install Flask-LDP
Usage
You only need to import and initialize your app
# Import dependencies
from flask import Flask
from flask_ldp import LDP
# Configure app and LDP logger
app = Flask(__name__)
ldp = LDP(app)
# Log to ldp
ldp.info("Message", extra={"data": "metadata",})
# Use LDP log handler in another logger
import logging
logger = logging.getLogger(__name__)
logger.addHandler(ldp.handler)
logger.info("Message")
Configuration options
The following options can be use to configure the ldp logger.
from flask import Flask
from flask_ldp import LDP
app = Flask(__name__)
# Use configuration from `app`
app.config["LDP_HOSTNAME"] = "gra3.logs.ovh.com"
app.config["LDP_TOKEN"] = "xxxxxx"
ldp = LDP(app)
# Provide configuration
config = {"LDP_HOSTNAME": "gra3.logs.ovh.com", "LDP_TOKEN": "xxxxx"}
ldp = LDP(app, config=config)
LDP_HOSTNAME
- the host to send messages to [default: 'gra3.logs.ovh.com']LDP_TOKEN
- the token [default: None]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Flask-LDP-0.1.0.tar.gz
(3.0 kB
view hashes)
Built Distribution
Close
Hashes for Flask_LDP-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 476761995926fab6ebc536757ac527a63939870090e683e0a52e4791efc9ec21 |
|
MD5 | f6cdfc3b7199cdcc0dda8eb5a44adddd |
|
BLAKE2b-256 | 64af8b4a77004cd941a9d6fa7ad1d782a92030048ce4d6b40ad2751557c8cdc4 |