getsentry / getsentry/sentry-python

Capture Loguru template

未关闭
#5,106 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
Feature Integration: Loguru Logs Python
主要语言
Python
星标
2.2k
派生
669
平均合并
1 天 1 小时
30 天内合并 PR
213

描述

### 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 [https://github.com/Delgan/loguru/pull/1413](https://github.com/Delgan/loguru/pull/1413). This issue is mostly for internal tracking purposes and extra context.
2. The other solution would be monkeypatching the [`_log` method](https://github.com/Delgan/loguru/blob/66d6de168ba6c286a46822f3acdcdbf0225bbad0/loguru/\_logger.py#L2028) 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.)

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。