-
Notifications
You must be signed in to change notification settings - Fork 23
/
logger.py
41 lines (39 loc) · 1.06 KB
/
logger.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
import sys
import logging.config
# We don't want to lose logs that occur before the dal being initialized
logging.getLogger().addHandler(logging.StreamHandler(sys.stdout))
logging.getLogger().setLevel(logging.INFO)
LOGGING_CONFIG = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'default': {
'level': "DEBUG",
'formatter': 'jsonFormatter',
'class': 'logging.StreamHandler'
},
'elastic': {
'level': "DEBUG",
'formatter': 'jsonFormatter',
'class': 'elastic_handler.ElasticHandler'
}
},
'loggers': {
'': { # root logger
'handlers': ['default'],
'level': "DEBUG",
'propagate': True
},
'elastic': { # elastic logger
'handlers': ['elastic'],
'level': "DEBUG",
'propagate': False
}
},
'formatters': {
'jsonFormatter': {
'()': 'json_formatter.JsonFormatter',
}
}
}
logging.config.dictConfig(LOGGING_CONFIG)