From 0c2a6f58021482504bd8bef23ea5fbb9d1e4cb54 Mon Sep 17 00:00:00 2001 From: z30043230 Date: Sat, 26 Jul 2025 10:58:29 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=BC=80=E5=8F=91=E8=87=AA=E6=8F=90?= =?UTF-8?q?=E3=80=91=E3=80=90=E5=AE=89=E5=85=A8=E3=80=91=E7=BB=91=E6=A0=B8?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=E6=97=A5=E5=BF=97=E8=AE=BE=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- profiler/affinity_cpu_bind/bind_core.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/profiler/affinity_cpu_bind/bind_core.py b/profiler/affinity_cpu_bind/bind_core.py index 344e997673..140c1cad05 100644 --- a/profiler/affinity_cpu_bind/bind_core.py +++ b/profiler/affinity_cpu_bind/bind_core.py @@ -18,6 +18,7 @@ import argparse import os import time import logging +from logging.handlers import RotatingFileHandler from datetime import datetime from datetime import timezone @@ -185,10 +186,16 @@ class BindCoreManager(): except RuntimeError as err: raise RuntimeError(msg) from err self.log_file = log_file_name - logging.basicConfig(filename=self.log_file, - level=logging.INFO, - filemode='w', - format='%(asctime)s-%(name)s-%(levelname)s-%(message)s') + file_handler = RotatingFileHandler( + filename=log_file_name, + maxBytes=10 * 1024 * 1024, + backupCount=3, + encoding='utf-8' + ) + file_handler.setFormatter(logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')) + file_handler.setLevel(logging.INFO) + logger.setLevel(logging.INFO) + logger.addHandler(file_handler) def _get_all_npu_id(self) -> None: get_npu_info_cmd = 'npu-smi info -l' -- Gitee