forked from karpathy/arxiv-sanity-preserver
-
Notifications
You must be signed in to change notification settings - Fork 20
/
logger.py
68 lines (59 loc) · 1.79 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
58
59
60
61
62
63
64
65
66
67
68
import logging
from logging.config import dictConfig
def logger_config(path='', info_filename='info.log', num_backups=5):
logging.getLogger('boto3').setLevel(logging.WARNING)
logging.getLogger('botocore').setLevel(logging.WARNING)
handlers = {
"console": {
"class": "logging.StreamHandler",
"level": "DEBUG",
"formatter": "f"
},
"info_file_handler": {
"class": "logging.handlers.RotatingFileHandler",
"level": "INFO",
"formatter": "f",
"filename": path + info_filename,
"maxBytes": 10485760,
"backupCount": num_backups,
"encoding": "utf8"
}
}
loggers = {
"elasticsearch": {
"level": "WARNING",
"propagate": "no"
},
"urllib3": {
"level": "WARNING",
"propagate": "no"
},
"tweepy": {
"level": "WARNING",
"propagate": "no"
},
"prawcore": {
"level": "WARNING",
"propagate": "no"
},
"requests": {
"level": "WARNING",
"propagate": "no"
},
}
root_hanlders = ["console", "info_file_handler",]
logging_config = dict(
version=1,
disable_existing_loggers=False,
formatters={
'f': {'format': '%(asctime)s - %(name)-12s %(levelname)-8s %(message)s'},
'syslog_f': {}
},
handlers=handlers,
loggers=loggers,
root={
"level": "DEBUG",
"handlers": root_hanlders
}
)
dictConfig(logging_config)