-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathlog.py
More file actions
40 lines (35 loc) · 903 Bytes
/
log.py
File metadata and controls
40 lines (35 loc) · 903 Bytes
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
import logging
import logging.config
import sentry_sdk
_log_configured = False
conf = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'simple': {
'format': '%(asctime)s %(name)s %(levelname)s %(message)s',
}
},
'handlers': {
'console': {
'class': 'logging.StreamHandler',
'level': 'INFO',
'formatter': 'simple',
'stream': 'ext://sys.stdout'
},
},
'root': {
'level': 'DEBUG',
'handlers': ['console']
}
}
def configure_logging():
global _log_configured
if not _log_configured:
sentry_sdk.init()
logging.config.dictConfig(conf)
log = logging.getLogger()
level = logging.INFO
log.setLevel(level)
log.info(f"Logging initialized with provided conf {conf}.")
_log_configured = True