Print Table with logger #2024
-
Hey ! Is there a way to render a Rich table with a rich handler logger ? with the following code it is not working from rich.console import Console
from rich.table import Table
import logging
from rich.logging import RichHandler
if __name__ == '__main__':
FORMAT = "%(message)s"
logging.basicConfig(
level="NOTSET", format=FORMAT, datefmt="[%X]", handlers=[RichHandler()]
)
log = logging.getLogger("rich")
table = Table(title=None,box=None)
table.add_column("", justify="right", style="cyan", no_wrap=True)
table.add_column("", style="magenta")
table.add_column("", justify="right", style="green underline")
table.add_row("Dec 20, 2019", "Star Wars: The Rise of Skywalker", "$952,110,690")
table.add_row("May 25, 2018", "Solo: A Star Wars Story", "$393,151,347")
table.add_row("Dec 15, 2017", "Star Wars Ep. V111: The Last Jedi", "$1,332,539,889")
table.add_row("Dec 16, 2016", "Rogue One: A Star Wars Story", "$1,332,439,889")
log.info(table)
>>> [15:26:11] INFO <rich.table.Table object at 0x7fd24263b040> |
Beta Was this translation helpful? Give feedback.
Answered by
willmcgugan
Mar 4, 2022
Replies: 1 comment 1 reply
-
Not without effort, but I would advise you not to do that. Even if Rich did that most loggers would not be able to. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
samsja
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not without effort, but I would advise you not to do that. Even if Rich did that most loggers would not be able to.