-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.py
68 lines (53 loc) · 1.74 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# # -*- coding: UTF-8 -*-
"""
╭﹌☆﹌﹌﹌☆﹌╮
∣ ∣
∣ ● ● ∣
∣ ▽ ∣
╰ —————— ╯
∣ ﹏ ﹏ ∣
╰∪———∪╯
┏┛┻━━━┛ ┻┓
┃ ━ ┃
┃ ┳┛ ┗┳ ┃
┃ ┃
┃ ┻ ┃
┗━┓ ┏━━━┛
┃ ┃
┃ ┗━━━━━━━━━ ━┓
┃ ┣┓
┃ ┏┛
┗━┓ ┓ ┏━━━┳ ┓ ┏━┛
┃ ┫ ┫ ┃ ┫ ┫
┗ ┻ ┛ ┗ ┻ ┛
"""
import logging
import logging.config
from flask import Flask, current_app
from config import config
app = Flask(__name__)
# logging.config.dictConfig(logger_conf)
def create_app():
app = Flask(__name__)
# 方法一日志设置
# handler = logging.FileHandler(filename="test.log", encoding='utf-8')
# handler.setLevel("DEBUG")
# format_ = "%(asctime)s[%(name)s][%(levelname)s] :%(levelno)s: %(message)s"
# formatter = logging.Formatter(format_)
# handler.setFormatter(formatter)
# app.logger.addHandler(handler)
# 方法二日志设置
logger_conf = config.LOGGER_CONF
logging.config.dictConfig(logger_conf)
return app
app = create_app()
@app.route("/", methods=["GET"])
def test():
current_app.logger.info("this is info")
current_app.logger.debug("this is debug")
current_app.logger.warning("this is warning")
current_app.logger.error("this is error")
current_app.logger.critical("this is critical")
return "ok"
if __name__ == "__main__":
app.run(debug=True)