forked from jbalogh/glow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
log_settings.py
43 lines (33 loc) · 896 Bytes
/
log_settings.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
import logging
import logging.handlers
import dictconfig
import settings_local as settings
fmt = '[%(asctime)s] %(name)s:%(levelname)s %(message)s'
cfg = {
'version': 1,
'filters': {},
'formatters': {
'file': {'format': fmt},
'syslog': {'format': '%s: %s' % (settings.SYSLOG_TAG, fmt)},
},
'handlers': {
'file': {
'()': logging.FileHandler,
'filename': settings.path('glow.log'),
'mode': 'a',
'formatter': 'file',
},
'syslog': {
'()': logging.handlers.SysLogHandler,
'facility': logging.handlers.SysLogHandler.LOG_USER,
'formatter': 'syslog',
},
},
'root': {
'level': logging.DEBUG,
'handlers': ['file'],
},
}
if settings.USE_SYSLOG:
cfg['root']['handlers'].append('syslog')
dictconfig.dictConfig(cfg)