-
Notifications
You must be signed in to change notification settings - Fork 699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix a problem of raw option with handler #136
Conversation
- Using raw option with handler, the message is cutted last 1 length
loguru/_handler.py
Outdated
if self._is_formatter_dynamic: | ||
formatted = message | ||
else: | ||
if hasattr(self._writer, "read"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to check other conditions of self._writer attributes.
Awesome, thanks for reporting and investigating this issue! So, to explain what is happening, one should look here: Lines 716 to 717 in 9250317
Why am I chopping the last char of the message? Because Loguru automatically adds Line 794 in 9250317
However, standard In order to prevent the message to be displayed with two trailing The bug occurs because the trailing Here is a small code snippet to play with: import logging
import sys
from loguru import logger
logger.remove()
logger.add(logging.StreamHandler(sys.stderr), format="{level.no} {message} [Not Chopped]")
logger.error("Allo?")
logger.opt(raw=True).error("hello") Your solution may work but I would like to avoid having to dynamically check for attributes at run-time in |
Thank you for very specific and kind replying! |
I finally fixed this issue in 49c5560. The workaround was quite simple, I just needed to specialize Anyway, I merged the new unit tests you added, thanks! 😃 |
When I test my application with loguru, I found something weird.
As you could see, If I use handler with raw option, I couldn't get full message on the log.
So I tried to find this solution then somewhat dealt with it with test code.