Log skip format change it format flags have not changed

This commit is contained in:
Clemens Schwaighofer
2025-11-19 17:42:47 +09:00
parent 51e9b1ce7c
commit f1788f057f
2 changed files with 7 additions and 0 deletions

View File

@@ -731,6 +731,7 @@ class Log(LogParent):
# formatter_console = logging.Formatter(format_string, datefmt=format_date)
formatter_console = logging.Formatter(format_string)
self.__set_time_format_for_console_formatter(formatter_console, console_format_type)
self.log_settings['console_format_type'] = console_format_type
return formatter_console
# MARK: console handler update
@@ -744,8 +745,12 @@ class Log(LogParent):
Arguments:
console_format_type {ConsoleFormat} -- _description_
"""
# skip if console not enabled
if not self.log_settings['console_enabled']:
return
# skip if format has not changed
if self.log_settings['console_format_type'] == console_format_type:
return
# update the formatter
self.handlers[self.CONSOLE_HANDLER].setFormatter(
self.__set_console_formatter(console_format_type)

View File

@@ -113,6 +113,8 @@ def main():
log.debug('Current logging format: %s', log.log_settings['console_format_type'])
log.update_console_formatter(ConsoleFormat.TIME | ConsoleFormat.LINENO)
log.info('Does hit show less')
log.update_console_formatter(ConsoleFormat.TIME | ConsoleFormat.LINENO)
log.info('Does hit show less B')
if __name__ == "__main__":