Skip to content

Commit

Permalink
Fix a logical bug about updating using the update_all option
Browse files Browse the repository at this point in the history
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
  • Loading branch information
deepjyoti30 committed Nov 19, 2020
1 parent e6d3361 commit f673adb
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions simber/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f673adb

Please sign in to comment.