forked from Brown-University-Library/theaterthatwasrome
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp_settings.py
More file actions
34 lines (29 loc) · 1.22 KB
/
app_settings.py
File metadata and controls
34 lines (29 loc) · 1.22 KB
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
31
32
33
import os
import logging
import logging.handlers
from django.core.exceptions import ImproperlyConfigured
def get_env_setting(setting):
try:
return os.environ[setting]
except KeyError:
error_msg = "Set the %s env variable" % setting
raise ImproperlyConfigured(error_msg)
BDR_SERVER = get_env_setting('ROME_BDR_SERVER')
PID_PREFIX = get_env_setting('ROME_PID_PREFIX')
BOOKS_PER_PAGE = 20
BDR_IDENTITY = get_env_setting('ROME_BDR_IDENTITY')
BDR_AUTH_CODE = get_env_setting('ROME_BDR_AUTH_CODE')
BDR_POST_URL = 'https://%s/api/items/v1/' % BDR_SERVER
XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink'
BDR_ANNOTATION_URL = 'https://%s/services/getMods/' % BDR_SERVER
def setup_logger(filename):
'''Configures a logger to write to console & <filename>.'''
formatter = logging.Formatter(u'%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger(u'logger')
logger.setLevel(logging.DEBUG)
file_handler = logging.handlers.RotatingFileHandler(filename, maxBytes=5000000, backupCount=5)
file_handler.setFormatter(formatter)
logger.addHandler(file_handler)
return logger
app_dir = os.path.dirname(os.path.abspath(__file__))
logger = setup_logger(os.path.join(app_dir, 'ttwr.log'))