-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
29 lines (26 loc) · 1.01 KB
/
config.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
import os
import logging
APP_NAME = "flaskr"
PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
class Config():
SQLALCHEMY_DATABASE_FILENAME = os.path.join(PROJECT_DIR, APP_NAME, "db/application.db")
SQLALCHEMY_DATABASE_URI = "sqlite:///{}".format(SQLALCHEMY_DATABASE_FILENAME)
SQLALCHEMY_TRACK_MODIFICATIONS = False
SECRET_KEY = os.urandom(32)
class Logger():
LOG_FILENAME = "/var/tmp/flaskr.log"
logger = logging.getLogger(APP_NAME)
logger.setLevel(logging.DEBUG)
# create file handler which logs even debug messages
fh = logging.FileHandler(LOG_FILENAME)
fh.setLevel(logging.DEBUG)
# create console handler with a higher log level
ch = logging.StreamHandler()
ch.setLevel(logging.ERROR)
# create formatter and add it to the handlers
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
ch.setFormatter(formatter)
fh.setFormatter(formatter)
# add the handlers to logger
logger.addHandler(ch)
logger.addHandler(fh)