Log-Request-ID is extension for handling request-ID in logging.
Project description
Log-Request-ID is an extension to handle request-IDs logs in popular python api frameworks.
Currently supported frameworks: flask
Requirements
python (3.6+)
Instalation
Install using pip
pip install log-request-id
Usage
Set LOG_REQUEST_ID_FRAMEWORK_SUPPORT to point to your framework of choice (section currently supported).
LOG_REQUEST_ID_FRAMEWORK_SUPPORT=flask
Init request-ID handler
Flask, with log_request_id.flask.init_flask_request_id_handler
from log_request_id import init_flask_request_id_handler
def create_flask_app():
app = Flask()
init_flask_request_id_handler(app)
Change log format (optional)
At this stage request_id is already present in log data, request-ID will be under request_id key.
logging.basicConfig(level=logging.WARNING, format='%(filename)s:%(levelname)s:%(request_id)s - %(message)s')
# or
logging.getlogger().setformatter(logging.formatter("%(asctime)s:%(name)s:level=%(levelname)s:%(request_id)s - %(message)s"))
For more advanced logger configuration see python’s logging module.
Warning if you will be adding custom handler or custom logging initialization use log_request_id.logging.RequestIdLogRecordFactory or log_request_id.logging.RequestIdLogFilter.
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
Built Distribution
Hashes for log_request_id-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 625b3a2003ec4625d28f426b59843453533ad1574794df33d16d9528bbff7f17 |
|
MD5 | 37462bf6930a9d40cbdce223431a6f67 |
|
BLAKE2b-256 | 0c56fcdeb991d5ea9b3a4102ee3488e8f4cb87bf2f12f0e7d196f13039112a28 |