Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
smallevil committed Nov 28, 2020
1 parent 4e03e04 commit f5a7540
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
23 changes: 18 additions & 5 deletions code/apps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,33 @@
# @Author: smallevil
# @Date: 2020-11-24 10:48:40
# @Last Modified by: smallevil
# @Last Modified time: 2020-11-28 19:19:14
# @Last Modified time: 2020-11-28 19:27:40

from flask import Flask
from .views.admin import admin
from .views.front import front
from .models.AdminModel import AdminModel
import os, logging, logging.handlers

app = Flask(__name__, template_folder='templates', static_folder='static', instance_relative_config=True)
app.config.from_object('config')
app.config.from_pyfile('config.py')
app.register_blueprint(front)
app.register_blueprint(admin)

if not app.config['DEBUG']:
import logging
log = logging.getLogger('werkzeug')
log.setLevel(logging.ERROR)

logger = logging.getLogger()
BASIC_FORMAT = "%(asctime)s:%(name)s:%(levelname)s:%(lineno)s:%(message)s"
DATE_FORMAT = '%Y-%m-%d %H:%M:%S'
formatter = logging.Formatter(BASIC_FORMAT, DATE_FORMAT)
fhlr = logging.handlers.TimedRotatingFileHandler(os.path.realpath(os.path.split(os.path.realpath(__file__))[0] + '/data/logs/access.log'), when='midnight',interval=1,backupCount=1) # 输出到文件的handler
fhlr.setFormatter(formatter)
logger.addHandler(fhlr)

if app.config['DEBUG']:
logger.setLevel(logging.DEBUG) # 也可以不设置,不设置就默认用logger的level
chlr = logging.StreamHandler() # 输出到控制台的handler
chlr.setFormatter(formatter)
logger.addHandler(chlr)
else:
logger.setLevel(logging.ERROR)
2 changes: 1 addition & 1 deletion code/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# @Author: smallevil
# @Date: 2020-11-24 10:48:40
# @Last Modified by: smallevil
# @Last Modified time: 2020-11-28 19:06:55
# @Last Modified time: 2020-11-28 19:31:52


from apps import app
Expand Down

0 comments on commit f5a7540

Please sign in to comment.