mirror of https://github.com/Textualize/rich.git
add option to not omit identical time values in log renderer
This commit is contained in:
parent
6c0696a2e4
commit
c4405f40f3
|
@ -18,12 +18,14 @@ class LogRender:
|
||||||
show_level: bool = False,
|
show_level: bool = False,
|
||||||
show_path: bool = True,
|
show_path: bool = True,
|
||||||
time_format: Union[str, FormatTimeCallable] = "[%x %X]",
|
time_format: Union[str, FormatTimeCallable] = "[%x %X]",
|
||||||
|
repeat_same_time: bool = False,
|
||||||
level_width: Optional[int] = 8,
|
level_width: Optional[int] = 8,
|
||||||
) -> None:
|
) -> None:
|
||||||
self.show_time = show_time
|
self.show_time = show_time
|
||||||
self.show_level = show_level
|
self.show_level = show_level
|
||||||
self.show_path = show_path
|
self.show_path = show_path
|
||||||
self.time_format = time_format
|
self.time_format = time_format
|
||||||
|
self.repeat_same_time = repeat_same_time
|
||||||
self.level_width = level_width
|
self.level_width = level_width
|
||||||
self._last_time: Optional[Text] = None
|
self._last_time: Optional[Text] = None
|
||||||
|
|
||||||
|
@ -58,7 +60,7 @@ class LogRender:
|
||||||
log_time_display = time_format(log_time)
|
log_time_display = time_format(log_time)
|
||||||
else:
|
else:
|
||||||
log_time_display = Text(log_time.strftime(time_format))
|
log_time_display = Text(log_time.strftime(time_format))
|
||||||
if log_time_display == self._last_time:
|
if log_time_display == self._last_time and not self.repeat_same_time:
|
||||||
row.append(Text(" " * len(log_time_display)))
|
row.append(Text(" " * len(log_time_display)))
|
||||||
else:
|
else:
|
||||||
row.append(log_time_display)
|
row.append(log_time_display)
|
||||||
|
|
|
@ -25,6 +25,7 @@ class RichHandler(Handler):
|
||||||
console (:class:`~rich.console.Console`, optional): Optional console instance to write logs.
|
console (:class:`~rich.console.Console`, optional): Optional console instance to write logs.
|
||||||
Default will use a global console instance writing to stdout.
|
Default will use a global console instance writing to stdout.
|
||||||
show_time (bool, optional): Show a column for the time. Defaults to True.
|
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.
|
||||||
show_level (bool, optional): Show a column for the level. 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.
|
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.
|
enable_link_path (bool, optional): Enable terminal link of path column to file. Defaults to True.
|
||||||
|
@ -60,6 +61,7 @@ class RichHandler(Handler):
|
||||||
console: Console = None,
|
console: Console = None,
|
||||||
*,
|
*,
|
||||||
show_time: bool = True,
|
show_time: bool = True,
|
||||||
|
repeat_same_time: bool = False,
|
||||||
show_level: bool = True,
|
show_level: bool = True,
|
||||||
show_path: bool = True,
|
show_path: bool = True,
|
||||||
enable_link_path: bool = True,
|
enable_link_path: bool = True,
|
||||||
|
@ -83,6 +85,7 @@ class RichHandler(Handler):
|
||||||
show_level=show_level,
|
show_level=show_level,
|
||||||
show_path=show_path,
|
show_path=show_path,
|
||||||
time_format=log_time_format,
|
time_format=log_time_format,
|
||||||
|
repeat_same_time=repeat_same_time,
|
||||||
level_width=None,
|
level_width=None,
|
||||||
)
|
)
|
||||||
self.enable_link_path = enable_link_path
|
self.enable_link_path = enable_link_path
|
||||||
|
|
Loading…
Reference in New Issue