Files
wordle-cheater/LOGGING.md

2.4 KiB

Logging-System

Das Wordle-Helper Logging-System protokolliert Seitenaufrufe und Suchanfragen ohne personenbezogene Daten wie IP-Adressen.

Log-Datei

  • Verzeichnis: logs/
  • Datei: logs/app.log
  • Format: UTF-8
  • Rotation: Automatische Rotation nach 7 Tagen
  • Backup: Komprimierte Backup-Dateien (30 Tage aufbewahrt)
  • Verzeichnis: Wird automatisch erstellt, falls es nicht existiert

Protokollierte Ereignisse

1. Seitenaufrufe (PAGE_VIEW)

2024-01-01 12:00:00 - INFO - PAGE_VIEW: index | User-Agent: Mozilla/5.0...
2024-01-01 12:00:01 - INFO - PAGE_VIEW: manifest | User-Agent: Mozilla/5.0...
2024-01-01 12:00:02 - INFO - PAGE_VIEW: service_worker | User-Agent: Mozilla/5.0...
2024-01-01 12:00:05 - INFO - SEARCH: pos='hallo' includes='' excludes='' sources=['OT'] | User-Agent: Mozilla/5.0...
2024-01-01 12:00:10 - INFO - SEARCH: pos='' includes='aei' excludes='rst' sources=['OT', 'WF'] | User-Agent: Mozilla/5.0...

Log-Format

  • Zeitstempel: ISO-Format (YYYY-MM-DD HH:MM:SS)
  • Ereignistyp: PAGE_VIEW oder SEARCH
  • Details: Spezifische Informationen je nach Ereignistyp
  • User-Agent: Gekürzt auf 100 Zeichen (ohne IP-Adressen)

Datenschutz

  • Keine IP-Adressen werden protokolliert
  • Keine persönlichen Daten werden gespeichert
  • User-Agent wird gekürzt und anonymisiert
  • Logs werden nicht ins Git-Repository übertragen (.gitignore)

Konfiguration

Das Logging ist in app.py konfiguriert:

logging.basicConfig(
    level=logging.INFO,
    format='%(asctime)s - %(levelname)s - %(message)s',
    handlers=[
        logging.FileHandler(logs_dir / 'app.log', encoding='utf-8'),
        logging.StreamHandler()
    ]
)

Automatische Log-Bereinigung

Das System bereinigt automatisch alte Log-Dateien:

  • Rotation: Nach 7 Tagen wird die aktuelle Log-Datei komprimiert
  • Backup: Komprimierte Dateien werden 30 Tage aufbewahrt
  • Format: Backup-Dateien: app_YYYYMMDD_HHMMSS.log.gz
  • Trigger: Bereinigung wird bei jedem Seitenaufruf geprüft
  • Fehlerbehandlung: Fehler bei der Bereinigung werden geloggt

Log-Analyse

Die Log-Datei kann mit Standard-Tools analysiert werden:

# Alle Suchanfragen anzeigen
grep "SEARCH:" logs/app.log

# Seitenaufrufe zählen
grep "PAGE_VIEW:" logs/app.log | wc -l

# Häufigste Suchparameter
grep "SEARCH:" logs/app.log | cut -d'|' -f1

# Logs-Verzeichnis anzeigen
ls -la logs/