From f673adb0ddff09cf2e5c3079057f407cb0def5d5 Mon Sep 17 00:00:00 2001 From: Deepjyoti Barman Date: Thu, 19 Nov 2020 20:02:20 +0530 Subject: [PATCH] Fix a logical bug about updating using the `update_all` option The `update_all` option needs to update all the streams based on the type of stream. If the stream is a file stream, the updated format will be file_format and otherwise it will be the console format --- simber/logger.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/simber/logger.py b/simber/logger.py index 1b9fb17..871121d 100644 --- a/simber/logger.py +++ b/simber/logger.py @@ -78,7 +78,7 @@ def __init__( # Update all instances, if asked to if kwargs.get("update_all", False): - self.update_format(self._console_format) + self.update_format(self._console_format, self._file_format) self.update_disable_file(self._disable_file) self.update_level(self._passed_level) @@ -227,11 +227,22 @@ def update_disable_file(self, disable_file): self._disable_file = disable_file self._disable_file_streams() - def update_format(self, format): + def update_format(self, format, file_format=None): """Update the format of all the instances. + + We need to update the instances seperately based + on the type of the stream. """ + valid_stdout_names = Default().valid_stdout_names + file_format = format if file_format is None else file_format + for stream in self._streams: - stream.format = format + if stream.stream_name in valid_stdout_names: + # Probably a console format + stream.format = format + else: + # Probably a file stream + stream.format = file_format def update_format_console(self, format): """Update the format for all the non file instances