-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogging_config.py
More file actions
51 lines (47 loc) · 1.33 KB
/
logging_config.py
File metadata and controls
51 lines (47 loc) · 1.33 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
45
46
47
48
49
50
51
"""ロギング設定を管理するモジュール。"""
import logging
import logging.config
import sys
LOGGING_CONFIG = {
"version": 1,
"disable_existing_loggers": False,
"formatters": {
"simpleFormatter": {
"format": (
"%(levelname)-8s %(asctime)s %(module)s "
"%(process)s %(pathname)s:%(lineno)d %(message)s"
)
}
},
"handlers": {
"consoleHandler": {
"class": "logging.StreamHandler",
"level": "DEBUG",
"formatter": "simpleFormatter",
"stream": sys.stdout,
},
"fileHandler": {
"class": "logging.handlers.TimedRotatingFileHandler",
"level": "DEBUG",
"formatter": "simpleFormatter",
"filename": "logs/python.log",
"when": "MIDNIGHT",
"interval": 1,
},
},
"loggers": {
"": { # root logger
"level": "DEBUG",
"handlers": ["consoleHandler", "fileHandler"],
"propagate": True,
},
"hoge": {
"level": "DEBUG",
"handlers": ["consoleHandler", "fileHandler"],
"propagate": False,
},
},
}
def setup_logging():
"""ロギング設定を初期化する。"""
logging.config.dictConfig(LOGGING_CONFIG)