Add a 'length' argument to the 'add' function supporting "max_length"#1224
Add a 'length' argument to the 'add' function supporting "max_length"#1224daniel347x wants to merge 1 commit intoDelgan:masterfrom
Conversation
…tion's MAX_LENGTH
|
Hi @daniel347x. Thank you for your interest in contributing to Loguru. Getting back at your comment at #173 (comment), it still seems natural to define a limit to the maximum length of the values displayed in the traceback. Since any arbitrary object can end up being printed, this avoids flooding if a long text or verbose dictionary happens to be logged. I agree it seems quite straightforward to simply add a new This is why for more advanced cases like yours, it's still possible to fully adapt exception formatting using a custom That being said, I understand it can frustrating not to be able to easily adjust the width limit. Your point makes me realize that it might be interesting to deprecate existing Rough idea: logger.add(sys.stderr, format="{time} {message}", traceback=lambda exc: logger.traceback(exc, width=999))Nothing concrete yet. But I think there's merit in considering a more generic approach, rather than a new If it's acceptable to you in the short term, however, I'd be happy to support a new environment variable to set the maximum length of the current traceback. I'd prefer something like |
This was a trivial change but of massive value for me to be able to simply pass a flag to the
logger.add()function controlling the maximum line length in stack trace diagnostics.The limit of 128 characters is too small, and the only reason I use Loguru is for this functionality, so I'm surprised it's not in place already given how trivial a change it is.
I do not object to the few seconds it takes to scroll to the right to see all variable values - not cut off by three dots - if it means saving hours or days of debugging time.
Note: The code uses the same approach as the existing design pattern of tying the default to a user-settable environment variable. Additionally, the default of 128 remains the same.
I also noticed the convention of single-word arguments to
add, so I chose "length" as the name of this argument.