From e893f148a49fca0f7487fcc1a18a921578eb6fbb 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=8F=8D=E5=90=88=E3=80=91=E3=80=90?= =?UTF-8?q?=E5=AE=89=E5=85=A8=E3=80=91=E7=BB=91=E6=A0=B8=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E8=AE=BE=E7=BD=AE=E6=96=87=E4=BB=B6=E5=A4=A7?= =?UTF-8?q?=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 aeb0647d7..8d8b32d8b 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