rich
rich copied to clipboard
[BUG] timefmt
- [X] I've checked docs and closed issues for possible solutions.
- [X] I can't find my issue in the FAQ.
Describe the bug
It is impossible to use a blank datefmt ("").
import logging
from logging import debug, error, info
from rich.logging import RichHandler
logging.basicConfig(format="%(message)s",
handlers=[RichHandler(rich_tracebacks=True)],
datefmt="",
)
error(f"something or other")
The above forces a date:
[12/07/23 09:35:40] ERROR something or other test.py:10
Changing the datefmt to be a single space instead works, but adds a space to the front of the line:
datefmt=" ",
ERROR something or other test.py:10
Platform
platform="Linux" enrich==1.2.7 rich==12.5.1 rich-cli==1.8.0 rich-logging==0.0.1 rich-rst==1.1.7
Thank you for your issue. Give us a little time to review it.
PS. You might want to check the FAQ if you haven't done so already.
This is an automated reply, generated by FAQtory
(I tried to create a patch, but failed -- not familiar enough with the internal flow handling of the date formatting)
Hey, my university software engineering group are willing to tackle this issue. Would it be possible to assign us? Here are our git usernames @albinkempe @lolindgr @ollisco @SihamShahoud and me @selmaozdere Thank you for your answer !!
Hello @hardaker. I have found a few solutions to this issue
1. using a lambda
logging.basicConfig(format="%(message)s",
handlers=[RichHandler(rich_tracebacks=True)],
datefmt=lambda x: "", # since we can provide a Callable
)
2. Using a escape char
logging.basicConfig(format="%(message)s",
handlers=[RichHandler(rich_tracebacks=True)],
datefmt="\0",
)
3. Using the RichHandlers log_time_format
property
logging.basicConfig(format="%(message)s",
handlers=[RichHandler(rich_tracebacks=True, log_time_format='')],
)