本文整理汇总了Python中flak.Flak.config["LOGGER_HANDLER_POLICY"]方法的典型用法代码示例。如果您正苦于以下问题:Python Flak.config["LOGGER_HANDLER_POLICY"]方法的具体用法?Python Flak.config["LOGGER_HANDLER_POLICY"]怎么用?Python Flak.config["LOGGER_HANDLER_POLICY"]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flak.Flak
的用法示例。
在下文中一共展示了Flak.config["LOGGER_HANDLER_POLICY"]方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_processor_exceptions
# 需要导入模块: from flak import Flak [as 别名]
# 或者: from flak.Flak import config["LOGGER_HANDLER_POLICY"] [as 别名]
def test_processor_exceptions(self):
app = Flak(__name__)
app.config["LOGGER_HANDLER_POLICY"] = "never"
@app.before_request
def before_request():
if trigger == "before":
1 // 0
@app.after_request
def after_request(response):
if trigger == "after":
1 // 0
return response
@app.route("/")
def index():
return "Foo"
@app.errorhandler(500)
def internal_server_error(cx, e):
return "Hello Server Error", 500
for trigger in "before", "after":
rv = app.test_client().get("/")
assert rv.status_code == 500
assert rv.data == b"Hello Server Error"
示例2: test_exception_logging
# 需要导入模块: from flak import Flak [as 别名]
# 或者: from flak.Flak import config["LOGGER_HANDLER_POLICY"] [as 别名]
def test_exception_logging(self):
out = StringIO()
app = Flak(__name__)
app.config["LOGGER_HANDLER_POLICY"] = "never"
app.logger_name = "flak_tests/test_exception_logging"
app.logger.addHandler(StreamHandler(out))
@app.route("/")
def index(cx):
1 // 0
rv = app.test_client().get("/")
assert rv.status_code == 500
assert b"Internal Server Error" in rv.data
err = out.getvalue()
assert "Exception on / [GET]" in err
assert "Traceback (most recent call last):" in err
assert "1 // 0" in err
assert "ZeroDivisionError:" in err