fixxed logger for app/init.py
This commit is contained in:
parent
1a92b81957
commit
6d37dbbfac
@ -1,13 +1,19 @@
|
||||
# app/__init__.py
|
||||
|
||||
import logging
|
||||
import threading
|
||||
import time
|
||||
import pygame
|
||||
|
||||
from flask import Flask
|
||||
from .utils.logging import setup_logging
|
||||
|
||||
from .utils.logging import setup_logging, cleanup_old_log_dirs
|
||||
from .routes.main import main_bp
|
||||
from .routes.admin import admin_bp
|
||||
from .routes.api import api_bp
|
||||
import threading
|
||||
import pygame
|
||||
from .bluetooth.manager import init_bluetooth
|
||||
|
||||
logger = logging.getLogger(__name__) # ← Logger für diese Datei
|
||||
|
||||
def create_app():
|
||||
app = Flask(__name__)
|
||||
@ -16,21 +22,9 @@ def create_app():
|
||||
app.config.from_object('config.Config')
|
||||
|
||||
# Logging zuerst (vor allem anderen)
|
||||
from .utils.logging import setup_logging, cleanup_old_log_dirs
|
||||
setup_logging(app)
|
||||
|
||||
# Täglicher Cleanup-Thread starten (einmalig)
|
||||
def daily_cleanup():
|
||||
while True:
|
||||
cleanup_old_log_dirs(90)
|
||||
time.sleep(86400) # 24 Stunden
|
||||
|
||||
cleanup_thread = threading.Thread(target=daily_cleanup, daemon=True)
|
||||
cleanup_thread.start()
|
||||
logger.info("Täglicher Log-Cleanup-Thread gestartet (24h Intervall)")
|
||||
|
||||
# Bluetooth initialisieren (Monitor-Thread startet automatisch)
|
||||
from .bluetooth.manager import init_bluetooth
|
||||
init_bluetooth()
|
||||
|
||||
# pygame initialisieren (einmalig)
|
||||
@ -48,4 +42,14 @@ def create_app():
|
||||
app.register_blueprint(admin_bp, url_prefix='/admin')
|
||||
app.register_blueprint(api_bp, url_prefix='/api')
|
||||
|
||||
# Täglicher Cleanup-Thread starten (einmalig)
|
||||
def daily_cleanup():
|
||||
while True:
|
||||
cleanup_old_log_dirs(90)
|
||||
time.sleep(86400) # 24 Stunden
|
||||
|
||||
cleanup_thread = threading.Thread(target=daily_cleanup, daemon=True)
|
||||
cleanup_thread.start()
|
||||
logger.info("Täglicher Log-Cleanup-Thread gestartet (24h Intervall)")
|
||||
|
||||
return app
|
||||
Loading…
x
Reference in New Issue
Block a user