SentryHandler cannot work with formatters
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
https://github.com/getsentry/raven-python/blob/af74e2f5c40b6b379d2c583a764fb6810fc1b819/raven/handlers/logging.py#L83
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.
@if-fi Pull request always welcome :)
Hi, Glad to see someone else had this issue. Was this pull request ever merged? I am currently using version 6.9.0 and formatted messages still don't work.