Skip to content

Commit

Permalink
Merge pull request #188 from ral-facilities/feature/configure-log-fil…
Browse files Browse the repository at this point in the history
…e-location-#182

Allow Log File Location to be Configurable
  • Loading branch information
MRichards99 authored Nov 18, 2020
2 parents 1596f73 + 45b5896 commit 463e3db
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions config.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"ICAT_URL": "https://localhost.localdomain:8181",
"icat_check_cert": false,
"log_level": "WARN",
"log_location": "/home/user1/datagateway-api/logs.log",
"debug_mode": false,
"generate_swagger": false,
"host": "127.0.0.1",
Expand Down
6 changes: 6 additions & 0 deletions datagateway_api/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ def get_log_level(self):
except KeyError:
sys.exit("Missing config value, log_level")

def get_log_location(self):
try:
return self.config["log_location"]
except KeyError:
sys.exit("Missing config value, log_location")

def is_debug_mode(self):
try:
return self.config["debug_mode"]
Expand Down
3 changes: 1 addition & 2 deletions datagateway_api/common/logger_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

from datagateway_api.common.config import config

log_level = "DEBUG"
LOG_FILE_NAME = Path(__file__).parent.parent / "logs.log"
LOG_FILE_NAME = Path(config.get_log_location())
logger_config = {
"version": 1,
"formatters": {
Expand Down

0 comments on commit 463e3db

Please sign in to comment.