-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvars.py
48 lines (35 loc) · 1.17 KB
/
vars.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
"""
SETTING GLOBALS
"""
TEAM = 'monitoring'
INTERVAL = 10
ONE_HOUR = 3600
EXIT_CODES = {
6: True, # 6 = vbYes - Yes was clicked
7: False # 7 = vbNo - No was clicked
}
EMERGANCY_KILL = "kill.bat"
POPUP_SCRIPT = "quick_popup.vbs"
LOGGER_FILE = "audit.log"
import sys
import logging
from logging.handlers import RotatingFileHandler
def create_rotating_log(path):
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
logger = logging.getLogger("alert_notification")
logger.setLevel(logging.INFO)
# add a rotating handler
handler = RotatingFileHandler(path, maxBytes=10*1024*1024,
backupCount=5)
handler.setFormatter(formatter)
logger.addHandler(handler)
return logger
# Default Logger
LOGGER = create_rotating_log(LOGGER_FILE)
def exception_handler(exc_type, value, traceback):
if issubclass(exc_type, KeyboardInterrupt):
LOGGER.info("stopping...")
sys.__excepthook__(exc_type, value, traceback)
LOGGER.exception(f"Uncaught exception: ", exc_info=(exc_type, value, traceback))
# Default Exception Hook
sys.excepthook = exception_handler