This repository was archived by the owner on Oct 23, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 656
SentryHandler cannot work with formatters #1039
Copy link
Copy link
Open
Description
I have a use case where I need to apply formatter to the log messages, that SentryHandler
sends to Sentry. In the code it looks like SentryHandles
is formatting the message, but, actually the newly formatted message is not saved in the log record.
Formatting works if we change line
raven-python/raven/handlers/logging.py
Line 83 in af74e2f
self.format(record) |
to
record.message = self.format(record)
You can easily recreate reproduce the problem like this
from logging import Formatter
from raven.handlers.logging import SentryHandler
sentry_handler = SentryHandler(client=client, level='ERROR')
sentry_handler.setFormatter(Formatter('This is my beautifully formatted message: %(message)s'))
logging.getLogger().addHandler(sentry_handler)
I am ready to send you a pull request for fixing this issue.
rebekahocampo