-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReciptDB.py
31 lines (25 loc) · 870 Bytes
/
ReciptDB.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
from app import app
from app.models import User, Recipt, Tag, UserTag, Invite
import logging
from logging.handlers import RotatingFileHandler
import os
@app.shell_context_processor
def make_shell_context():
return {
'db': db,
'Recipt': Recipt,
'Tag': Tag,
'UserTag': UserTag,
'Invite': Invite,
}
if not app.debug:
if not os.path.exists('logs'):
os.mkdir('logs')
file_handler = RotatingFileHandler('logs/ReciptDB.log', maxBytes=10240,
backupCount=10)
file_handler.setFormatter(logging.Formatter(
'%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno)d]'))
file_handler.setLevel(logging.INFO)
app.logger.addHandler(file_handler)
app.logger.setLevel(logging.INFO)
app.logger.info('ReciptDB startup')