-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlogconfig.py
30 lines (26 loc) · 1.28 KB
/
logconfig.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
import logging
import logging.config
_init = False
dict_config = {'version': 1,
'formatters': {'simple': {
'format': '%(asctime)s - %(filename)s:%(lineno)3s %(funcName)20s - %(levelname)s - %(message)s'}},
'handlers': {'console': {'class': 'logging.StreamHandler',
'level': 'DEBUG',
'formatter': 'simple',
'stream': 'ext://sys.stdout'},
'file': {'class': 'logging.handlers.RotatingFileHandler',
'level': 'DEBUG',
'formatter': 'simple',
'filename': '/tmp/iwubi.log',
'maxBytes': 1048576,
'backupCount': 3}},
'root': {'level': 'DEBUG', 'handlers': ['console', 'file']}}
def get_logger():
global _init
if not _init:
# with open(os.path.join(os.path.dirname(__file__), 'logconfig.yaml'), 'r') as f:
# config = yaml.safe_load(f.read())
# logging.config.dictConfig(config)
logging.config.dictConfig(dict_config)
_init = True
return logging.getLogger()