get_task_logs
Retrieve execution logs for specific scheduled tasks in Qinglong Panel to monitor task performance and troubleshoot issues.
Instructions
获取青龙面板中指定任务的执行日志
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| task_id | Yes | 任务 ID |
Implementation Reference
- server.py:247-294 (handler)Handler for the 'get_task_logs' tool. Fetches task details using the Qinglong API, then retrieves and formats the execution logs if available.elif tool_name == "get_task_logs": task_id = arguments.get("task_id") try: url = f"{QINGLONG_URL}/open/crons/{task_id}" headers = {"Authorization": f"Bearer {token}"} resp = requests.get(url, headers=headers, timeout=10) result = resp.json() except Exception as e: response = { "jsonrpc": "2.0", "id": request["id"], "error": {"code": -32603, "message": f"请求失败: {str(e)}"} } print(json.dumps(response), flush=True) continue if result.get("code") == 200: cron = result["data"] log_path = cron.get("log_path", "") if log_path: try: log_url = f"{QINGLONG_URL}/open/crons/{task_id}/log" log_resp = requests.get(log_url, headers=headers, timeout=10) log_result = log_resp.json() if log_result.get("code") == 200: log_content = log_result["data"] output = f"任务 {task_id} ({cron.get('name')}) 的执行日志:\n\n{log_content}" else: output = f"获取日志失败: {log_result}" except Exception as e: output = f"读取日志失败: {str(e)}" else: output = f"任务 {task_id} ({cron.get('name')}) 暂无执行日志" response = { "jsonrpc": "2.0", "id": request["id"], "result": {"content": [{"type": "text", "text": output}]} } else: response = { "jsonrpc": "2.0", "id": request["id"], "error": {"code": -32603, "message": f"获取任务信息失败: {result}"} }
- server.py:112-122 (registration)Registration of the 'get_task_logs' tool in the tools/list response, including its name, description, and input schema definition.{ "name": "get_task_logs", "description": "获取青龙面板中指定任务的执行日志", "inputSchema": { "type": "object", "properties": { "task_id": {"type": "integer", "description": "任务 ID"} }, "required": ["task_id"] } },
- server.py:115-121 (schema)Input schema for the 'get_task_logs' tool, defining the required 'task_id' parameter."inputSchema": { "type": "object", "properties": { "task_id": {"type": "integer", "description": "任务 ID"} }, "required": ["task_id"] }