forked from georgeherby/MADevice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
62 lines (48 loc) · 1.4 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
53
54
55
56
57
58
59
60
61
62
import logging
import sys
from threading import Thread
from colorlog import ColoredFormatter
from alert import alert_thread
from bot import run
from run_args import get_args
class InfoFilter(logging.Filter):
def filter(self, rec):
return rec.levelno in (logging.DEBUG, logging.INFO)
args = get_args()
log = logging.getLogger('__name__')
if args.verbose:
log.setLevel(logging.DEBUG)
else:
log.setLevel(logging.INFO)
formatter = ColoredFormatter(
'%(log_color)s [%(asctime)s] [%(threadName)16s] [%(module)14s:%(lineno)d]' +
' [%(levelname)8s] %(message)s',
datefmt='%m-%d %H:%M:%S',
reset=True,
log_colors={
'DEBUG': 'purple',
'INFO': 'cyan',
'WARNING': 'yellow',
'ERROR': 'red',
'CRITICAL': 'red,bg_white',
},
secondary_log_colors={},
style='%'
)
# Redirect messages lower than WARNING to stdout
stdout_hdlr = logging.StreamHandler(sys.stdout)
stdout_hdlr.setFormatter(formatter)
log_filter = InfoFilter()
stdout_hdlr.addFilter(log_filter)
stdout_hdlr.setLevel(5)
# Redirect messages equal or higher than WARNING to stderr
stderr_hdlr = logging.StreamHandler(sys.stderr)
stderr_hdlr.setFormatter(formatter)
stderr_hdlr.setLevel(logging.WARNING)
log.addHandler(stdout_hdlr)
log.addHandler(stderr_hdlr)
# Start ScanChecker
alert_thread = Thread(target=alert_thread, name='ScanChecker')
alert_thread.start()
# Start Discord Bot
run()