I am using RichHander to format log output inside Python. While this works great locally, when I run inside GitLab, it seems to default to using a terminal that is 80 characters wide. This makes the output fairly difficult to read and scan quickly. I would like to change this default width for the RichHandler, but I don't see a way to do it.
Is there a way to set a minimum console width for the Python RichHandler log handler?
# Pseudocode:
import logging
from rich.logging import RichHandler
def setup_logging():
logger = logging.getLogger('myLogger')
richFormatter = logging.Formatter('%(message)s')
richHandler = RichHandler()
# Something like: richHandler.setMinimumWidth(255)
richHandler.setFormatter(richFormatter)
logger.addHandler(richHandler)
Add console=Console(width=255) to the handler constructor.
E.g.
from rich.console import Console
richHandler = RichHandler(console=Console(width=255))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With