-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
52 lines (38 loc) · 1.22 KB
/
main.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
import sys
import logging
import logging.config
from configs import LOGGING_CONFIG_DICT, logging_config_fun, LOGGING_FILE_CONFIG
def dict_config():
"""Config logging using a dictionary."""
logging.config.dictConfig(LOGGING_CONFIG_DICT)
def file_config():
"""Config logging using a file."""
logging.config.fileConfig(LOGGING_FILE_CONFIG)
def code_config():
"""Config logging using code."""
logging_config_fun()
CONFIG_OPTIONS = {
"1": dict_config,
"2": code_config,
"3": file_config
}
def run():
"""Run example."""
chosen_config_type = input("""
What type of configuration would you like to try?
1) Dict config *default
2) Code config
3) File config
""")
chosen_config_type = chosen_config_type or "1"
CONFIG_OPTIONS[chosen_config_type]()
app_logger = logging.getLogger("app")
views_logger = logging.getLogger("app.views")
models_logger = logging.getLogger("app.models")
app_logger.info("Info message in app logger, data: %s", { "test": "data" })
views_logger.debug("Debug message in views logger, data: %s", { "test": "data" })
models_logger.info("Info message in models logger, data: %s", { "test": "data" })
"""
Run sample
"""
run()