@@ -39,6 +39,8 @@ class Log:
3939 """
4040
4141 _logger = logging .getLogger (__name__ )
42+ last_log_text = ""
43+ repeat_log = False
4244
4345 @classmethod
4446 def apply_logging_config (cls , level , log_file_name ):
@@ -88,33 +90,45 @@ def build_msg(cls, txt, *args):
8890 skip = True
8991 else :
9092 string_args .append (args [i ])
91- return txt .format (* string_args )
93+ if (log_text := txt .format (* string_args )) != cls .last_log_text :
94+ cls .last_log_text = log_text
95+ cls .repeat_log = False
96+ return log_text
97+ if not cls .repeat_log :
98+ cls .repeat_log = True
99+ return "Repeating...."
100+ return None
92101
93102 @classmethod
94103 def info (cls , txt , * args ):
95104 """Log info messages."""
96105 if cls ._logger .isEnabledFor (logging .INFO ):
97- cls ._logger .info (cls .build_msg (txt , * args ), stacklevel = 2 )
106+ if (log_text := cls .build_msg (txt , * args )):
107+ cls ._logger .info (log_text , stacklevel = 2 )
98108
99109 @classmethod
100110 def debug (cls , txt , * args ):
101111 """Log debug messages."""
102112 if cls ._logger .isEnabledFor (logging .DEBUG ):
103- cls ._logger .debug (cls .build_msg (txt , * args ), stacklevel = 2 )
113+ if (log_text := cls .build_msg (txt , * args )):
114+ cls ._logger .debug (log_text , stacklevel = 2 )
104115
105116 @classmethod
106117 def warning (cls , txt , * args ):
107118 """Log warning messages."""
108119 if cls ._logger .isEnabledFor (logging .WARNING ):
109- cls ._logger .warning (cls .build_msg (txt , * args ), stacklevel = 2 )
120+ if (log_text := cls .build_msg (txt , * args )):
121+ cls ._logger .warning (log_text , stacklevel = 2 )
110122
111123 @classmethod
112124 def error (cls , txt , * args ):
113125 """Log error messages."""
114126 if cls ._logger .isEnabledFor (logging .ERROR ):
115- cls ._logger .error (cls .build_msg (txt , * args ), stacklevel = 2 )
127+ if (log_text := cls .build_msg (txt , * args )):
128+ cls ._logger .error (log_text , stacklevel = 2 )
116129
117130 @classmethod
118131 def critical (cls , txt , * args ):
119132 """Log critical messages."""
120- cls ._logger .critical (cls .build_msg (txt , * args ), stacklevel = 2 )
133+ if (log_text := cls .build_msg (txt , * args )):
134+ cls ._logger .critical (log_text , stacklevel = 2 )
0 commit comments