Skip to content
This repository was archived by the owner on Oct 23, 2023. It is now read-only.
This repository was archived by the owner on Oct 23, 2023. It is now read-only.

SentryHandler cannot work with formatters #1039

Open
@if-fi

Description

@if-fi

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

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions