Skip to content

Commit

Permalink
Merge pull request #1108 from efenka/master
Browse files Browse the repository at this point in the history
add option to not omit identical time values in log renderer
  • Loading branch information
willmcgugan committed Mar 16, 2021
2 parents ec86300 + c235db4 commit 5d716be
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion rich/_log_render.py
Expand Up @@ -18,12 +18,14 @@ def __init__(
show_level: bool = False,
show_path: bool = True,
time_format: Union[str, FormatTimeCallable] = "[%x %X]",
omit_repeated_times: bool = True,
level_width: Optional[int] = 8,
) -> None:
self.show_time = show_time
self.show_level = show_level
self.show_path = show_path
self.time_format = time_format
self.omit_repeated_times = omit_repeated_times
self.level_width = level_width
self._last_time: Optional[Text] = None

Expand Down Expand Up @@ -58,7 +60,7 @@ def __call__(
log_time_display = time_format(log_time)
else:
log_time_display = Text(log_time.strftime(time_format))
if log_time_display == self._last_time:
if log_time_display == self._last_time and self.omit_repeated_times:
row.append(Text(" " * len(log_time_display)))
else:
row.append(log_time_display)
Expand Down
3 changes: 3 additions & 0 deletions rich/logging.py
Expand Up @@ -25,6 +25,7 @@ class RichHandler(Handler):
console (:class:`~rich.console.Console`, optional): Optional console instance to write logs.
Default will use a global console instance writing to stdout.
show_time (bool, optional): Show a column for the time. Defaults to True.
omit_repeated_times (bool, optional): Omit repetition of the same time. Defaults to True.
show_level (bool, optional): Show a column for the level. Defaults to True.
show_path (bool, optional): Show the path to the original log call. Defaults to True.
enable_link_path (bool, optional): Enable terminal link of path column to file. Defaults to True.
Expand Down Expand Up @@ -60,6 +61,7 @@ def __init__(
console: Console = None,
*,
show_time: bool = True,
omit_repeated_times: bool = True,
show_level: bool = True,
show_path: bool = True,
enable_link_path: bool = True,
Expand All @@ -83,6 +85,7 @@ def __init__(
show_level=show_level,
show_path=show_path,
time_format=log_time_format,
omit_repeated_times=omit_repeated_times,
level_width=None,
)
self.enable_link_path = enable_link_path
Expand Down

0 comments on commit 5d716be

Please sign in to comment.