Auto-updater, limites CPU 60% et facturation corrigés
Build and Push Docker Image / build-and-push (push) Successful in 1m55s

This commit is contained in:
xavier committed 2026-08-22 01:10:40 +02:00
1 parent 71d6f51ee0
commit b4ed2947d4
15 files changed
+7413 -122

No files matched your search

+24 -16
View File
@@ -1,28 +1,36 @@
import logging
from logging.handlers import TimedRotatingFileHandler
import os
from datetime import datetime
# Le fichier de destination pour les logs locaux
LOG_FILE = "aethas_logs.txt"
LOG_DIR = "/DATA/AppData/MULTI-IA-AETHAS38"
os.makedirs(LOG_DIR, exist_ok=True)
LOG_FILE = os.path.join(LOG_DIR, "aethas_logs.txt")
logger = logging.getLogger("Aethas38")
logger.setLevel(logging.INFO)
if not logger.handlers:
# Conformité LCEN : Conservation des logs de connexion sur 365 jours (1 an)
handler = TimedRotatingFileHandler(LOG_FILE, when="midnight", interval=1, backupCount=365, encoding="utf-8")
handler.suffix = "%Y-%m-%d"
formatter = logging.Formatter('[%(asctime)s] [%(levelname)s] [%(name)s] %(message)s', datefmt='%Y-%m-%d %H:%M:%S')
handler.setFormatter(formatter)
logger.addHandler(handler)
def log_event(niveau, source, message):
"""
Enregistre un événement dans le fichier de log local.
Déclenche l'envoi d'un e-mail si le niveau est ERROR ou CRITICAL.
"""
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
log_line = f"[{timestamp}] [{niveau}] [{source}] {message}\n"
msg_formate = f"[{source}] {message}"
# 1. Écriture sécurisée dans le fichier de log local
try:
with open(LOG_FILE, "a", encoding="utf-8") as f:
f.write(log_line)
except Exception as e:
print(f"ÉCHEC D'ÉCRITURE LOG : Impossible d'écrire dans {LOG_FILE} : {e}")
if niveau.upper() == "INFO": logger.info(msg_formate)
elif niveau.upper() == "WARNING": logger.warning(msg_formate)
elif niveau.upper() == "ERROR": logger.error(msg_formate)
elif niveau.upper() == "CRITICAL": logger.critical(msg_formate)
print(f"[{datetime.now().strftime('%H:%M:%S')}] [{niveau}] {msg_formate}")
# 2. Déclenchement de l'alerte e-mail pour la phase de Debug (Import local pour éviter l'import circulaire)
if niveau in ["ERROR", "CRITICAL"]:
try:
from modules.debug_mailer import envoyer_alerte_debug
envoyer_alerte_debug(niveau, source, message)
except Exception as mail_error:
print(f"ÉCHEC D'ENVOI E-MAIL : Impossible d'avertir l'administrateur : {mail_error}")
pass