forked from mozilla/kitsune
-
Notifications
You must be signed in to change notification settings - Fork 0
/
log_settings.py
80 lines (75 loc) · 2.33 KB
/
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import logging
from django.conf import settings
from django.utils.log import dictConfig
import celery.conf
import celery.log
config = {
'version': 1,
'disable_existing_loggers': True,
'root': {
'level': logging.ERROR,
'handlers': ['sentry'],
},
'formatters': {
'default': {
'format': '{0}: %(asctime)s %(name)s:%(levelname)s %(message)s: '
'%(pathname)s:%(lineno)s'.format(settings.SYSLOG_TAG),
}
},
'handlers': {
'syslog': {
'class': 'logging.handlers.SysLogHandler',
'formatter': 'default',
'facility': logging.handlers.SysLogHandler.LOG_LOCAL7,
'level': settings.LOG_LEVEL,
},
'mail_admins': {
'class': 'django.utils.log.AdminEmailHandler',
'level': logging.ERROR,
},
'sentry': {
'class': 'raven.contrib.django.handlers.SentryHandler',
'level': logging.ERROR,
},
'console': {
'class': 'logging.StreamHandler',
'formatter': 'default',
'level': settings.LOG_LEVEL,
},
},
'loggers': {
'k': {
'handlers': ['syslog'],
'propogate': True,
# Use the most permissive setting. It is filtered in the handlers.
'level': logging.DEBUG,
},
'django.request': {
'handlers': ['syslog'],
'propogate': True,
# Use the most permissive setting. It is filtered in the handlers.
'level': logging.DEBUG,
},
'raven': {
'level': logging.ERROR,
'handlers': ['syslog', 'mail_admins'],
'propagate': False,
},
'sentry.errors': {
'level': logging.ERROR,
'handlers': ['syslog', 'mail_admins'],
'propagate': False,
},
},
}
if settings.DEBUG:
config['formatters']['default']['datefmt'] = '%H:%M:%S'
config['loggers']['k']['handlers'] = ['console']
config['loggers']['django.request']['handlers'] = ['console']
config['root']['handlers'] = ['console']
else:
task_log = logging.getLogger('k.celery')
task_proxy = celery.log.LoggingProxy(task_log)
celery.conf.CELERYD_LOG_FILE = task_proxy
celery.conf.CELERYD_LOG_COLOR = False
dictConfig(config)