This is an automated email from the ASF dual-hosted git repository.

yongzao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new f0bcd43ee95 [AINODE] Fix logger level filter (#16195)
f0bcd43ee95 is described below

commit f0bcd43ee954615a7fd56813ae027dc35edb9dbf
Author: Li Yu Heng <[email protected]>
AuthorDate: Mon Aug 18 16:55:10 2025 +0800

    [AINODE] Fix logger level filter (#16195)
---
 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

Reply via email to