Skip to content

Capture Loguru template #5106

@sentrivana

Description

@sentrivana

Problem Statement

We currently don't have access to the raw message before formatting in Loguru logs so we can't add it as sentry.message.template.

Solution Brainstorm

  1. The most feasible way forward is getting the template from Loguru directly. Submitted a PR for that Add template to record Delgan/loguru#1413. This issue is mostly for internal tracking purposes and extra context.
  2. The other solution would be monkeypatching the _log method that takes care of creating the record. This would enable us to get the raw message since the method gets it as an argument. However, we don't have a way to get the formatted message afterwards: all processing happens directly in the _log function and nothing is returned; instead, the records are sent to the sinks directly. We could find a way to associate a raw message we've seen in the monkeypatched _log method with the message we receive in our sink, but that'd mean introducing some kind of book-keeping structure which I'd like to avoid. (And since Loguru's maintainer said they'd be fine with 1, we're not doing this unless anything changes.)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions