Feature: Log-Ausgabe in Datei und Konsole
Erweitert Logging-Konfiguration für besseres Debugging: Änderungen: - Logs werden in Datei UND Konsole ausgegeben - Log-Datei: ~/.config/DocuMentor/logs/documentor_TIMESTAMP.log - Konsole: Nur INFO und höher (für Live-Monitoring) - Datei: Alles ab DEBUG (für detaillierte Analyse) - Automatischer Timestamp im Dateinamen - UTF-8 Encoding für deutsche Umlaute Log-Verzeichnis: - Linux: ~/.config/DocuMentor/logs/ - Windows: %APPDATA%\DocuMentor\logs\ - macOS: ~/Library/Application Support/DocuMentor/logs/ Beispiel: documentor_20251228_134000.log Nützlich für: - Performance-Analyse des Saxon-Worker-Pools - Debugging von Transformations-Problemen - Nachverfolgung von Batch-Operationen 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
+33
-6
@@ -10,12 +10,39 @@ from conf import app_settings
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Haupteinstiegspunkt der Anwendung."""
|
"""Haupteinstiegspunkt der Anwendung."""
|
||||||
# Logging konfigurieren
|
# Logging konfigurieren - sowohl Datei als auch Konsole
|
||||||
logging.basicConfig(
|
from datetime import datetime
|
||||||
level=logging.DEBUG,
|
|
||||||
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
# Log-Verzeichnis erstellen (im selben Verzeichnis wie config.json)
|
||||||
datefmt='%H:%M:%S'
|
from conf import config_path
|
||||||
)
|
|
||||||
|
log_dir = config_path.parent / "logs"
|
||||||
|
log_dir.mkdir(exist_ok=True)
|
||||||
|
|
||||||
|
# Log-Dateiname mit Timestamp
|
||||||
|
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
||||||
|
log_file = log_dir / f"documentor_{timestamp}.log"
|
||||||
|
|
||||||
|
# Root-Logger konfigurieren
|
||||||
|
logger = logging.getLogger()
|
||||||
|
logger.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
|
# Formatter für alle Handler
|
||||||
|
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s", datefmt="%H:%M:%S")
|
||||||
|
|
||||||
|
# Handler 1: Datei (alles ab DEBUG)
|
||||||
|
file_handler = logging.FileHandler(log_file, encoding="utf-8")
|
||||||
|
file_handler.setLevel(logging.DEBUG)
|
||||||
|
file_handler.setFormatter(formatter)
|
||||||
|
logger.addHandler(file_handler)
|
||||||
|
|
||||||
|
# Handler 2: Konsole (alles ab INFO)
|
||||||
|
console_handler = logging.StreamHandler(sys.stdout)
|
||||||
|
console_handler.setLevel(logging.INFO)
|
||||||
|
console_handler.setFormatter(formatter)
|
||||||
|
logger.addHandler(console_handler)
|
||||||
|
|
||||||
|
logging.info(f"Logging initialisiert: {log_file}")
|
||||||
|
|
||||||
# QApplication-Instanz erstellen
|
# QApplication-Instanz erstellen
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
|
|||||||
Reference in New Issue
Block a user