forked from MITLibraries/oastats-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.tmpl.py
58 lines (45 loc) · 1.6 KB
/
settings.tmpl.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import logging
import sys
from pipeline.log import RequestFilter
# Configure which fields from the Apache log will be retained and what field
# they will be mapped to in the final JSON object.
APACHE_FIELD_MAPPINGS = {
'%h': 'ip_address',
'%t': 'time',
'%r': 'request',
'%>s': 'status',
'%{Referer}i': 'referer',
'%{User-agent}i': 'user_agent',
'%b': 'filesize',
}
# Should be a tuple with either host and port, MongoDB URI, or empty
# ex: ('localhost', 27017,) or ('mongodb://localhost:27017',)
# Remember the trailing comma!
MONGO_CONNECTION = ('localhost', 27017,)
MONGO_DB = 'oastats'
MONGO_COLLECTION = 'requests'
MONGO_SUMMARY_COLLECTION = 'summary'
# Location of the GeoIP database
GEOIP_DB = ''
# DSpace identity service
DSPACE_IDENTITY_SERVICE = 'http://dspace-dev.mit.edu/ws/oastats'
# Configure logging for the application
log = logging.getLogger('pipeline')
info_hdlr = logging.StreamHandler(sys.stdout)
info_hdlr.setLevel(logging.INFO)
err_hdlr = logging.StreamHandler(sys.stderr)
err_hdlr.setFormatter(logging.Formatter('%(msg)s: %(inputfile)s:%(inputline)s'))
err_hdlr.setLevel(logging.ERROR)
log.addHandler(info_hdlr)
log.addHandler(err_hdlr)
# Configure logging for request logger
req = logging.getLogger('req_log')
ip_hdlr = logging.FileHandler('logs/ip.log')
ip_hdlr.addFilter(RequestFilter('IP_ERROR'))
req_hdlr = logging.FileHandler('logs/req.log')
req_hdlr.addFilter(RequestFilter('REQUEST_ERROR'))
meta_hdlr = logging.FileHandler('logs/meta.log')
meta_hdlr.addFilter(RequestFilter('DSPACE_ERROR'))
req.addHandler(ip_hdlr)
req.addHandler(meta_hdlr)
req.addHandler(req_hdlr)