Skip to content

Commit

Permalink
inverse option to not omit identical time values in log renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
fnep committed Mar 15, 2021
1 parent c4405f4 commit c235db4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions rich/_log_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ def __init__(
show_level: bool = False,
show_path: bool = True,
time_format: Union[str, FormatTimeCallable] = "[%x %X]",
repeat_same_time: bool = False,
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.repeat_same_time = repeat_same_time
self.omit_repeated_times = omit_repeated_times
self.level_width = level_width
self._last_time: Optional[Text] = None

Expand Down Expand Up @@ -60,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 and not self.repeat_same_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
6 changes: 3 additions & 3 deletions rich/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +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.
repeat_same_time (bool, optional): Do not omit repetition of the same time. Defaults to False.
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 @@ -61,7 +61,7 @@ def __init__(
console: Console = None,
*,
show_time: bool = True,
repeat_same_time: bool = False,
omit_repeated_times: bool = True,
show_level: bool = True,
show_path: bool = True,
enable_link_path: bool = True,
Expand All @@ -85,7 +85,7 @@ def __init__(
show_level=show_level,
show_path=show_path,
time_format=log_time_format,
repeat_same_time=repeat_same_time,
omit_repeated_times=omit_repeated_times,
level_width=None,
)
self.enable_link_path = enable_link_path
Expand Down

0 comments on commit c235db4

Please sign in to comment.