-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogger.py
More file actions
44 lines (42 loc) · 1.31 KB
/
logger.py
File metadata and controls
44 lines (42 loc) · 1.31 KB
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
import logging.config
def setup_logger():
"""
Start one logger with INFO level on the console and one with DEBUG level
in file that will be rewritten once it reaches 100kB.
"""
logging_config = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'standard': {
# pylint: disable=line-too-long
'format': "%(asctime)s [%(levelname)-5.5s] [%(module)s] (%(funcName)s) : %(message)s"
}
},
'handlers': {
'console': {
'level': 'INFO',
'formatter': 'standard',
'class': 'logging.StreamHandler',
'stream': 'ext://sys.stdout'
},
'file': {
'level': 'DEBUG',
'formatter': 'standard',
'class': 'logging.handlers.RotatingFileHandler',
'filename': 'plotter.log',
'maxBytes': 100000,
'backupCount': 1,
'encoding': 'utf-8',
'delay': False
}
},
'loggers': {
'': {
'handlers': ['console', 'file'],
'level': 'DEBUG',
'propagate': True
}
}
}
logging.config.dictConfig(logging_config)