From 4063ca772e713d75e5420d97360f83a6056bb3b3 Mon Sep 17 00:00:00 2001 From: mocobk Date: Sun, 7 Jan 2024 11:12:39 +0800 Subject: [PATCH] fix: log duplication problem --- common/logger.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/logger.py b/common/logger.py index 59d079a..7847c09 100644 --- a/common/logger.py +++ b/common/logger.py @@ -5,6 +5,8 @@ class Logger: + HANDLER = logging.StreamHandler() + def __init__(self): self.formatter = logging.Formatter( "%(asctime)s [%(levelname)s] %(message)s", datefmt="%Y-%m-%d %H:%M:%S" @@ -13,7 +15,7 @@ def __init__(self): self.logger = logging.getLogger("sonic-driver-core") self.set_log_level(logging.INFO) - ch = logging.StreamHandler() + ch = self.HANDLER ch.setFormatter(self.formatter) self.logger.addHandler(ch)