-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
45 lines (35 loc) · 1.06 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
import logging
import colorlog
from controller.OutputController import OutputController
from enums.ServicesEnum import ServicesEnum
logger = logging.getLogger(__name__)
def setup_logging():
color_formatter = colorlog.ColoredFormatter(
"%(log_color)s%(levelname)-8s | %(name)-26s | %(message)s",
log_colors={
"DEBUG": "white",
"INFO": "green",
"WARNING": "yellow",
"ERROR": "red",
"CRITICAL": "bold_red",
},
)
console_handler = logging.StreamHandler()
console_handler.setFormatter(color_formatter)
console_handler.setLevel(logging.DEBUG)
logging.basicConfig(
level=logging.DEBUG,
handlers=[console_handler],
)
def main():
setup_logging()
logic = OutputController(debug=False)
try:
logic.start()
except KeyboardInterrupt:
logging.info("Keyboard interrupt received. Shutting down...")
finally:
logic.stop()
logging.info("All services stopped. Exiting")
if __name__ == "__main__":
main()