add logger

This commit is contained in:
2025-04-28 10:18:28 +02:00
parent 7abe3d8cc0
commit 5923bfd7ff

View File

@@ -5,9 +5,18 @@ from pathlib import Path
from src.backend.database import Database
db = Database()
import loguru
import sys
log = loguru.logger
log.remove()
log.add("application.log", rotation="1 week", retention="1 month")
log.add(
sys.stdout,
)
def recreateFile(name, app_id, filetype, open=True) -> Path:
def recreateFile(name: str, app_id: int, filetype: str, open: bool = True) -> Path:
"""
recreateFile creates a file from the database and opens it in the respective program, if the open parameter is set to True.
@@ -24,6 +33,7 @@ def recreateFile(name, app_id, filetype, open=True) -> Path:
"""
path = db.recreateFile(name, app_id, filetype=filetype)
path = Path(path)
log.info(f"File created: {path}")
if open:
if os.getenv("OS") == "Windows_NT":
path = path.resolve()