-
Notifications
You must be signed in to change notification settings - Fork 40
/
logger.py
57 lines (50 loc) · 1.24 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import logging.config
import sys
import types
LOGGING_CONFIG = {
'disable_existing_loggers': False,
'formatters': {
'standard': {
'format': '%(asctime)s [%(levelname)s] %(message)s',
'datefmt': '%Y-%m-%dT%H:%M:%S',
},
},
'handlers': {
'file': {
'class': 'logging.FileHandler',
'filename': 'perfrunner.log',
'formatter': 'standard',
'mode': 'w',
},
'stream': {
'class': 'logging.StreamHandler',
'formatter': 'standard',
},
},
'loggers': {
'': {
'handlers': ['stream', 'file'],
'level': logging.INFO,
'propagate': True,
},
'boto3': {
'level': logging.WARNING,
},
'botocore': {
'level': logging.WARNING,
},
'paramiko': {
'level': logging.WARNING,
},
'requests': {
'level': logging.ERROR,
},
},
'version': 1,
}
def error(self, msg, *args, **kwargs):
self.error(msg, *args, **kwargs)
sys.exit(1)
logging.config.dictConfig(LOGGING_CONFIG)
logger = logging.getLogger()
logger.interrupt = types.MethodType(error, logger)