Skip to content

Commit

Permalink
#13: Use config class
Browse files Browse the repository at this point in the history
  • Loading branch information
keiranjprice101 committed Jul 26, 2019
1 parent c6bcff6 commit 4b6f0e9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
5 changes: 4 additions & 1 deletion common/constants.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
from common.config import config


class Constants:
DATABASE_URL = "mysql+pymysql://root:rootpw@localhost:13306/icatdb"
DATABASE_URL = config.get_db_url()
6 changes: 3 additions & 3 deletions common/logger_setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging.config

from common.config import config

log_level = "DEBUG"
LOG_FILE_NAME = "../logs.log"
Expand All @@ -9,15 +9,15 @@
"format": "[%(asctime)s] {%(module)s:%(filename)s:%(funcName)s:%(lineno)d} %(levelname)s -%(message)s ",
}},
"handlers": {"default": {
"level": "DEBUG",
"level": config.get_log_level(),
"formatter": "default",
"class": "logging.handlers.RotatingFileHandler",
"filename": LOG_FILE_NAME,
"maxBytes": 5000000,
"backupCount": 10
}},
"root": {
"level": log_level,
"level": config.get_log_level(),
"handlers": ["default"]
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from flask import Flask
from flask_restful import Api

from common.config import config
from common.logger_setup import setup_logger
from src.resources.entities.dataset_type_endpoints import *
from src.resources.entities.applications_endpoints import *
Expand Down Expand Up @@ -200,4 +201,4 @@


if __name__ == "__main__":
app.run(debug=True)
app.run(debug=config.is_debug_mode())

0 comments on commit 4b6f0e9

Please sign in to comment.