Configure log folder in json file

This commit is contained in:
Julian Stirling 2025-06-03 14:03:46 +01:00
parent 7c30f7a720
commit 4ef74c42c3
5 changed files with 25 additions and 20 deletions

View file

@ -9,14 +9,11 @@ from .legacy_api import add_v2_endpoints
from ..logging import configure_logging, retrieve_log, retrieve_log_from_file
def customise_server(server: ThingServer):
def customise_server(server: ThingServer, log_folder: str):
"""Customise the server with additional endpoints, etc."""
configure_logging()
configure_logging(log_folder)
add_v2_endpoints(server)
try:
add_static_files(server.app)
except RuntimeError:
print("Failed to add static files - you will have to do without them!")
add_static_files(server.app)
# Add an endpoint to get the logs - (directly calling the FastAPI decorator)
server.app.get("/log/")(retrieve_log)
@ -27,10 +24,10 @@ def serve_from_cli(argv: Optional[list[str]] = None):
"""Start the server from the command line"""
args = cli.parse_args(argv)
try:
config, server = None, None
config = cli.config_from_args(args)
log_folder = config.get("log_folder", "./openflexure/logs")
server = cli.server_from_config(config)
customise_server(server)
customise_server(server, log_folder)
uvicorn.run(
server.app,
host=args.host,