Skip to content
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

On exception, the traceback is concatenated to the message #1081

Open
sergeykad opened this issue Feb 13, 2024 · 1 comment
Open

On exception, the traceback is concatenated to the message #1081

sergeykad opened this issue Feb 13, 2024 · 1 comment
Labels
question Further information is requested

Comments

@sergeykad
Copy link

sergeykad commented Feb 13, 2024

In the case of execution of logger.exception("Oops") reading Record.msg in a custom logging.Handler implementation returns the original message with traceback concatenated to it. Since I need to use a different format for different handlers this is quite problematic. This is also different from Python logging, which stores traceback in Record.exc_text and concatenates it later with the formatted message.

This is somewhat related to #1080

@Delgan Delgan added the question Further information is requested label Feb 17, 2024
@Delgan
Copy link
Owner

Delgan commented Feb 17, 2024

This is because {exception} is automatically appended to your format for convenience. This behavior is disabled when using a function as the formatter.

logger.add(custom_handler, format=lambda _: "{message}")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants