# # Copyright 2026 The InfiniFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # from api.apps import login_required from api.utils.api_utils import get_json_result, get_data_error_result from common.log_utils import get_log_levels, set_log_level @manager.route("/config/log", methods=["GET"]) # noqa: F821 @login_required async def get_logger_levels(): """ Get current log levels for all packages. --- tags: - System responses: 200: description: Return current log levels """ return get_json_result(data=get_log_levels()) @manager.route("/config/log", methods=["PUT"]) # noqa: F821 @login_required async def set_logger_level(): """ Set log level for a package. --- tags: - System parameters: - in: body name: body required: true schema: type: object properties: pkg_name: type: string description: Package name (e.g., "rag.utils.es_conn") level: type: string description: Log level (DEBUG, INFO, WARNING, ERROR) responses: 200: description: Log level updated successfully """ from quart import request data = await request.get_json() if not data or "pkg_name" not in data or "level" not in data: return get_data_error_result(message="pkg_name and level are required") pkg_name = data["pkg_name"] level = data["level"] success = set_log_level(pkg_name, level) if success: return get_json_result(data={"pkg_name": pkg_name, "level": level}) else: return get_data_error_result(message=f"Invalid log level: {level}")