Refactor: add rxtx debugger log
This commit is contained in:
parent
ea31261bff
commit
0ee3825563
5 changed files with 264 additions and 9 deletions
49
app.py
49
app.py
|
@ -18,6 +18,10 @@ from detector_worker.core.singleton_managers import (
|
|||
from detector_worker.communication.websocket_handler import WebSocketHandler
|
||||
from detector_worker.utils.system_monitor import get_system_metrics
|
||||
from detector_worker.utils.error_handler import ErrorHandler, create_logger
|
||||
from detector_worker.utils.websocket_debug import (
|
||||
setup_websocket_logging, enable_websocket_debug, disable_websocket_debug,
|
||||
get_websocket_debug_status
|
||||
)
|
||||
|
||||
# Setup logging
|
||||
logger = create_logger("detector_worker.main", logging.INFO)
|
||||
|
@ -54,6 +58,9 @@ async def lifespan(app: FastAPI):
|
|||
|
||||
logger.info("Configuration validation passed")
|
||||
|
||||
# Setup WebSocket logging based on configuration
|
||||
setup_websocket_logging()
|
||||
|
||||
# Log startup information
|
||||
config = config_manager.get_all()
|
||||
logger.info(f"Max streams: {config.get('max_streams', 5)}")
|
||||
|
@ -211,6 +218,48 @@ async def reload_configuration():
|
|||
raise HTTPException(status_code=500, detail="Internal server error")
|
||||
|
||||
|
||||
@app.get("/debug/websocket")
|
||||
async def get_websocket_debug_status():
|
||||
"""Get current WebSocket debugging status."""
|
||||
try:
|
||||
return get_websocket_debug_status()
|
||||
except Exception as e:
|
||||
logger.error(f"Error getting WebSocket debug status: {e}")
|
||||
raise HTTPException(status_code=500, detail="Internal server error")
|
||||
|
||||
|
||||
@app.post("/debug/websocket/enable")
|
||||
async def enable_websocket_debugging():
|
||||
"""Enable WebSocket debugging."""
|
||||
try:
|
||||
enable_websocket_debug()
|
||||
logger.info("WebSocket debugging enabled via API")
|
||||
return {
|
||||
"success": True,
|
||||
"message": "WebSocket debugging enabled",
|
||||
"status": get_websocket_debug_status()
|
||||
}
|
||||
except Exception as e:
|
||||
logger.error(f"Error enabling WebSocket debugging: {e}")
|
||||
raise HTTPException(status_code=500, detail="Internal server error")
|
||||
|
||||
|
||||
@app.post("/debug/websocket/disable")
|
||||
async def disable_websocket_debugging():
|
||||
"""Disable WebSocket debugging."""
|
||||
try:
|
||||
disable_websocket_debug()
|
||||
logger.info("WebSocket debugging disabled via API")
|
||||
return {
|
||||
"success": True,
|
||||
"message": "WebSocket debugging disabled",
|
||||
"status": get_websocket_debug_status()
|
||||
}
|
||||
except Exception as e:
|
||||
logger.error(f"Error disabling WebSocket debugging: {e}")
|
||||
raise HTTPException(status_code=500, detail="Internal server error")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import uvicorn
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue