This is an automated email from the ASF dual-hosted git repository. liyuheng pushed a commit to branch lyh/ainode/fix-log-level in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit cd209a121b27b454fa41c1b2ec13dda1df63e96b Author: liyuheng <[email protected]> AuthorDate: Mon Aug 18 14:47:42 2025 +0800 done --- iotdb-core/ainode/ainode/core/constant.py | 6 ------ iotdb-core/ainode/ainode/core/log.py | 13 +++++++++++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/iotdb-core/ainode/ainode/core/constant.py b/iotdb-core/ainode/ainode/core/constant.py index 5a55b4d283b..220066b8419 100644 --- a/iotdb-core/ainode/ainode/core/constant.py +++ b/iotdb-core/ainode/ainode/core/constant.py @@ -73,12 +73,6 @@ AINODE_LOG_DIR = "logs" # AINode log LOG_FILE_TYPE = ["all", "info", "warning", "error"] AINODE_LOG_FILE_NAME_PREFIX = "log_ainode_" -AINODE_LOG_FILE_NAMES = [ - "log_ainode_all.log", - "log_ainode_info.log", - "log_ainode_warning.log", - "log_ainode_error.log", -] AINODE_LOG_FILE_LEVELS = [logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR] DEFAULT_LOG_LEVEL = logging.INFO INFERENCE_LOG_FILE_NAME_PREFIX_TEMPLATE = ( diff --git a/iotdb-core/ainode/ainode/core/log.py b/iotdb-core/ainode/ainode/core/log.py index f89250b4cdd..f0423e493a6 100644 --- a/iotdb-core/ainode/ainode/core/log.py +++ b/iotdb-core/ainode/ainode/core/log.py @@ -85,6 +85,9 @@ class BaseLogger: interval=1, encoding="utf-8", ) + if LOG_FILE_TYPE[i] != "all": + file_handler.setLevel(logging.NOTSET) + file_handler.addFilter(LogLevelFilter(file_level)) # set renamer def universal_namer( @@ -145,3 +148,13 @@ class Logger(BaseLogger): def __init__(self, log_file_name_prefix: str = AINODE_LOG_FILE_NAME_PREFIX): super().__init__(log_file_name_prefix=log_file_name_prefix) + + +class LogLevelFilter(logging.Filter): + + def __init__(self, level: int): + super().__init__() + self.level = level + + def filter(self, record: logging.LogRecord) -> bool: + return record.levelno == self.level
