log für kategorien-Bug

This commit is contained in:
hubobel 2026-06-24 16:48:11 +02:00
parent a55559977b
commit 1628ef198c

70
app.py
View file

@ -9,6 +9,32 @@ from pathlib import Path
from influxdb_client import InfluxDBClient from influxdb_client import InfluxDBClient
from datetime import datetime, timedelta from datetime import datetime, timedelta
from collections import defaultdict from collections import defaultdict
from datetime import datetime
import shutil
import logging
import platform
# --------------------------------------------------
# Logging
# --------------------------------------------------
if platform.system() == "Windows":
log_dir = Path(__file__).parent / "logs"
else:
log_dir = Path.home() / "logs"
category_logger = logging.getLogger("categories")
log_dir.mkdir(exist_ok=True)
log_file = log_dir / "ing.log"
logging.basicConfig(
filename=log_file,
level=logging.INFO,
format="%(asctime)s [%(levelname)s] %(message)s",
)
logging.info(
"[app.py] === Scriptstart ==="
)
app = Flask(__name__) app = Flask(__name__)
@ -557,7 +583,16 @@ def delete_category(category):
"w", "w",
encoding="utf-8" encoding="utf-8"
) as f: ) as f:
if CATEGORIES_FILE.exists():
shutil.copy2(
CATEGORIES_FILE,
str(CATEGORIES_FILE) + ".bak"
)
logging.warning(
f"Kategorien werden gespeichert. "
f"Anzahl Kategorien={len(categories)} "
f"Keys={list(categories.keys())}"
)
json.dump( json.dump(
categories, categories,
f, f,
@ -589,7 +624,16 @@ def add_category():
"w", "w",
encoding="utf-8" encoding="utf-8"
) as f: ) as f:
if CATEGORIES_FILE.exists():
shutil.copy2(
CATEGORIES_FILE,
str(CATEGORIES_FILE) + ".bak"
)
logging.warning(
f"Kategorien werden gespeichert. "
f"Anzahl Kategorien={len(categories)} "
f"Keys={list(categories.keys())}"
)
json.dump( json.dump(
categories, categories,
f, f,
@ -645,7 +689,16 @@ def add_word(category):
"w", "w",
encoding="utf-8" encoding="utf-8"
) as f: ) as f:
if CATEGORIES_FILE.exists():
shutil.copy2(
CATEGORIES_FILE,
str(CATEGORIES_FILE) + ".bak"
)
logging.warning(
f"Kategorien werden gespeichert. "
f"Anzahl Kategorien={len(categories)} "
f"Keys={list(categories.keys())}"
)
json.dump( json.dump(
categories, categories,
f, f,
@ -679,7 +732,16 @@ def delete_word(category, word):
"w", "w",
encoding="utf-8" encoding="utf-8"
) as f: ) as f:
if CATEGORIES_FILE.exists():
shutil.copy2(
CATEGORIES_FILE,
str(CATEGORIES_FILE) + ".bak"
)
logging.warning(
f"Kategorien werden gespeichert. "
f"Anzahl Kategorien={len(categories)} "
f"Keys={list(categories.keys())}"
)
json.dump( json.dump(
categories, categories,
f, f,