diff --git a/src/corelibs/logging_handling/log.py b/src/corelibs/logging_handling/log.py index 15bdea5..22c51f8 100644 --- a/src/corelibs/logging_handling/log.py +++ b/src/corelibs/logging_handling/log.py @@ -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) diff --git a/test-run/logging_handling/log.py b/test-run/logging_handling/log.py index 2a11213..e1bd095 100644 --- a/test-run/logging_handling/log.py +++ b/test-run/logging_handling/log.py @@ -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__":