Skip to main content
Donate to the Python Software Foundation or Purchase a PyCharm License to Benefit the PSF! Donate Now

Request lifecycle logger for flask

Project description


该工程是 Python 版本的 request-lifecycle,用于收集请求过程中的日志


在 Flask 中在请求生命周期的两段嵌入如下代码。在嵌入 before_request 后,可以通过 g.trace_id 获取请求的 ID。

from flask import Flask
from request_lifecycle import RequestLifecycleMiddleware

app = Flask(__name__)

def before_request():
    """在这里放入一个配置好 log-server 的前置中间件
    RequestLifecycleMiddleware.before_request(host='', port='3000', app_name='whatever',

def after_request(response: Flask.response_class):
    """在这里放入一个捕捉 response 的中间件
    return response

Project details

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
request_lifecycle-1.0.0-py3.6.egg (6.8 kB) Copy SHA256 hash SHA256 Egg 3.6
request_lifecycle-1.0.0-py3-none-any.whl (4.0 kB) Copy SHA256 hash SHA256 Wheel py3
request_lifecycle-1.0.0.tar.gz (2.7 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page