烧瓶使用的烧瓶扩展件

flask-easylog的Python项目详细描述


烧瓶方便

烧瓶应用程序的帮助日志管理

安装

pip install flask-easylog

git clone https://github.com/fraoustin/flask-easylog.git
cd flask-easylog
python setup.py install

您可以通过

python -m unittest discover -s test

使用量

from flask import Flask, request, current_app
from logging import DEBUG, INFO, ERROR

from flask_easylog import EasyLog, FMT_ACCESS_LOG, log, SpecificLevelLog, Api, Ui

app = Flask(__name__)
app.secret_key = 'super secret string'
app.logger.setLevel(INFO)

app.logger.info("before add EasyLog")

EasyLog(app,
    fmt = FMT_ACCESS_LOG,
    afterlog = True,
    beforelog = True)
app.register_blueprint(Api(url_prefix='/api'))
app.register_blueprint(Ui(url_prefix='/ui'))
app.logger.info("after add EasyLog")

@app.route("/")
def hello():
    current_app.logger.critical("critical from hello")
    current_app.logger.error("error from hello")
    current_app.logger.info("info from hello")
    current_app.logger.debug("debug from hello")
    return "Hello World!"

@app.route("/one")
@log(DEBUG)
def one():
    current_app.logger.critical("critical from one")
    current_app.logger.error("error from one")
    current_app.logger.info("info from one")
    current_app.logger.debug("debug from one")
    return "Hello World!"

@app.route("/two")
@log
def two():
    current_app.logger.critical("critical from two")
    current_app.logger.error("error from two")
    current_app.logger.info("info from two")
    current_app.logger.debug("debug from two")
    return "Hello World!"

@app.route("/three")
@log(ERROR)
def three():
    current_app.logger.critical("critical from three")
    current_app.logger.error("error from three")
    current_app.logger.info("info from three")
    current_app.logger.debug("debug from three")
    return "Hello World!"

@app.route("/four")
def four():
    current_app.logger.critical("critical from four")
    current_app.logger.error("error from four")
    current_app.logger.info("info from four")
    current_app.logger.debug("debug from four")
    return "Hello World!"

SpecificLevelLog['four']=ERROR

if __name__ == "__main__":
    app.logger.info("before run")
    app.run(host="0.0.0.0", port=8080)

功能

  • 按筛选器和@管理请求太长
  • 按规则管理级别(按API更改)
  • 更改打印功能的工作
  • 使用goaccess测试access.log
  • 如果状态>;=500且非模式调试,则为调试添加fct

0.1.0伏

  • 初始化
  • 添加请求ID
  • 从配置和请求中添加信息
  • 添加信息时间戳

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java需要64位jdk 1.5 for windows   eclipse运算符+对于参数类型java是未定义的。双,爪哇。双人   未下载文件扩展名为的java文件   java不支持带有POST的媒体类型   从动态创建的多个EditText读取文本时发生java错误   java无法为同一xpath单击多个按钮   如何在Java中动态格式化字符串   java Android Clear Middle活动   多线程Java内存模型volatile和x86   git在Java中通过Jgit忽略文件或文件夹   java“决策无法区分输入的备选方案1、2…”   子类的javajpa继承   java需要弄清楚如何操作mutator来弄清楚一个类,教授说,我对如何操作感到困惑   java如何使用JDBC将数据从文件复制到PostgreSQL?