nixpkgs/pkgs/by-name/me/mealie/mealie-logs-to-stdout.patch
Litchi Pi c1373dd3ab mealie: init at v1.2.0
Signed-off-by: Litchi Pi <litchi.pi@proton.me>
2024-02-23 07:15:20 +01:00

103 lines
3.7 KiB
Diff

diff --git a/mealie/core/root_logger.py b/mealie/core/root_logger.py
index 29db504f..3da5ef84 100644
--- a/mealie/core/root_logger.py
+++ b/mealie/core/root_logger.py
@@ -9,7 +9,6 @@ DATA_DIR = determine_data_dir()
from .config import get_app_settings # noqa E402
-LOGGER_FILE = DATA_DIR.joinpath("mealie.log")
DATE_FORMAT = "%d-%b-%y %H:%M:%S"
LOGGER_FORMAT = "%(levelname)s: %(asctime)s \t%(message)s"
@@ -40,19 +39,17 @@ def get_logger_config():
level=log_level,
)
- output_file_handler = logging.FileHandler(LOGGER_FILE)
handler_format = logging.Formatter(LOGGER_FORMAT, datefmt=DATE_FORMAT)
- output_file_handler.setFormatter(handler_format)
# Stdout
stdout_handler = logging.StreamHandler(sys.stdout)
stdout_handler.setFormatter(handler_format)
return LoggerConfig(
- handlers=[output_file_handler, stdout_handler],
+ handlers=[stdout_handler],
format="%(levelname)s: %(asctime)s \t%(message)s",
date_format="%d-%b-%y %H:%M:%S",
- logger_file=LOGGER_FILE,
+ logger_file=None,
level=log_level,
)
diff --git a/mealie/routes/admin/admin_log.py b/mealie/routes/admin/admin_log.py
index ac12c12e..0de98b99 100644
--- a/mealie/routes/admin/admin_log.py
+++ b/mealie/routes/admin/admin_log.py
@@ -1,6 +1,5 @@
from fastapi import APIRouter
-from mealie.core.root_logger import LOGGER_FILE
from mealie.core.security import create_file_token
router = APIRouter(prefix="/logs")
@@ -9,15 +8,13 @@ router = APIRouter(prefix="/logs")
@router.get("/{num}")
async def get_log(num: int):
"""Doc Str"""
- with open(LOGGER_FILE, "rb") as f:
- log_text = tail(f, num)
- return log_text
+ return ""
@router.get("")
async def get_log_file():
"""Returns a token to download a file"""
- return {"fileToken": create_file_token(LOGGER_FILE)}
+ return {"fileToken": create_file_token("nofile")}
def tail(f, lines=20):
diff --git a/mealie/routes/admin/admin_maintenance.py b/mealie/routes/admin/admin_maintenance.py
index 23ef8369..322b580f 100644
--- a/mealie/routes/admin/admin_maintenance.py
+++ b/mealie/routes/admin/admin_maintenance.py
@@ -6,7 +6,6 @@ from pathlib import Path
from fastapi import APIRouter, HTTPException
-from mealie.core.root_logger import LOGGER_FILE
from mealie.pkgs.stats import fs_stats
from mealie.routes._base import BaseAdminController, controller
from mealie.schema.admin import MaintenanceSummary
@@ -73,8 +72,6 @@ class AdminMaintenanceController(BaseAdminController):
Get the maintenance summary
"""
log_file_size = 0
- with contextlib.suppress(FileNotFoundError):
- log_file_size = os.path.getsize(LOGGER_FILE)
return MaintenanceSummary(
data_dir_size=fs_stats.pretty_size(fs_stats.get_dir_size(self.folders.DATA_DIR)),
@@ -85,7 +82,7 @@ class AdminMaintenanceController(BaseAdminController):
@router.get("/logs", response_model=MaintenanceLogs)
def get_logs(self, lines: int = 200):
- return MaintenanceLogs(logs=tail_log(LOGGER_FILE, lines))
+ return MaintenanceLogs(logs="")
@router.get("/storage", response_model=MaintenanceStorageDetails)
def get_storage_details(self):
@@ -137,9 +134,6 @@ class AdminMaintenanceController(BaseAdminController):
Purges the logs
"""
try:
- with contextlib.suppress(FileNotFoundError):
- os.remove(LOGGER_FILE)
- LOGGER_FILE.touch()
return SuccessResponse.respond("Logs cleaned")
except Exception as e:
raise HTTPException(status_code=500, detail=ErrorResponse.respond("Failed to clean logs")) from e