-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
32 lines (27 loc) · 1.04 KB
/
Copy pathconfig.py
File metadata and controls
32 lines (27 loc) · 1.04 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
import logging
from logging.handlers import RotatingFileHandler
# Zentrale Einstellungen (direkt auf Modulebene, damit alle Funktionen sie nutzen können)
LOG_DATEI = "system_monitor.log"
INTERVALL_SEKUNDEN = 60
CPU_SCHWELLENWERT = 70
RAM_SCHWELLENWERT = 85
DISK_SCHWELLENWERT = 85
TEMP_SCHWELLENWERT = 75 # Temperatur-Schwellenwert in °C
WARNUNG_NACH_MESSUNGEN = 2
POPUP_AKTIVIERT = False # Popup-Benachrichtigungen aktivieren/deaktivieren
def setup_logging():
"""Konfiguriert das rotierende Logging zentral."""
logger = logging.getLogger()
if any(getattr(handler, "system_monitor_handler", False)
for handler in logger.handlers):
return
log_handler = RotatingFileHandler(
LOG_DATEI,
maxBytes=1 * 1024 * 1024, # 1 Megabyte
backupCount=3, # 3 Backups
encoding="utf-8"
)
log_handler.setFormatter(logging.Formatter("%(asctime)s - %(levelname)s - %(message)s"))
logger.setLevel(logging.INFO)
log_handler.system_monitor_handler = True
logger.addHandler(log_handler)