Moving debug to customise_server

This commit is contained in:
Beth Probert 2026-03-05 10:38:10 +00:00
parent c3ad127f1c
commit b9e9e29210

View file

@ -72,9 +72,10 @@ def set_shutdown_function(shutdown_function: Callable[[], None]) -> None:
def customise_server(
server: lt.ThingServer, application_config: OFMApplicationData
server: lt.ThingServer, application_config: OFMApplicationData,
debug: bool
) -> None:
"""Customise the server with additional endpoints, etc."""
"""Customise the server with additional endpoints, debug mode etc."""
if DEVELOPER_MODE:
# Allow CORS in developer mode for easier testing with the webapp
server.app.add_middleware(
@ -88,6 +89,10 @@ def customise_server(
add_v2_endpoints(server)
add_static_files(server.app, application_config.data_folder)
# Configure logging to DEBUG if requested in CLI args.
if debug:
lt.logs.configure_thing_logger(logging.DEBUG)
# Add an endpoint to get the logs - (directly calling the FastAPI decorator)
server.app.get("/log/")(retrieve_log)
server.app.get("/logfile/")(retrieve_log_from_file)
@ -114,7 +119,8 @@ def serve_from_cli(argv: Optional[list[str]] = None) -> None:
configure_logging(application_config.log_folder)
server = lt.ThingServer.from_config(lt_config)
customise_server(server, application_config)
debug = True if args.debug else False
customise_server(server, application_config, debug)
def shutdown_call() -> None:
try: