loguru icon indicating copy to clipboard operation
loguru copied to clipboard

Add `template` to record

Open sentrivana opened this issue 1 month ago • 2 comments

template contains the raw, unformatted message body before any colorization or interpolation is applied. Useful for structured logging tools/visualizers like Sentry.

Hope I covered everything -- I'm available for changes if anything is off. 🙏🏻

Ref https://github.com/Delgan/loguru/issues/1349

sentrivana avatar Nov 12 '25 16:11 sentrivana

Hey! Thank you very much for the PR. Sorry, once again, for the delay...

I'm just wondering: don't you also need *args (and **kwargs to a lesser extent) to be accessible in the template? I'm thinking it could fix #1344 at the same time.

Delgan avatar Nov 30 '25 09:11 Delgan

Heyo, no worries, thanks for getting back to me. 🙏🏻

I'm just wondering: don't you also need *args (and **kwargs to a lesser extent) to be accessible in the template? I'm thinking it could fix https://github.com/Delgan/loguru/issues/1344 at the same time.

That would be ideal, but wasn't sure if it was ok from your POV (in the original issue you only mentioned adding the template, so I assumed you wouldn't add the args/kwargs).

Happy to add it to the PR. What's the best way to go about it?

  1. Add args (and potentially kwargs) additionally on the record alongside template
  2. Make template a simple class with args, kwargs, and raw as attributes

Just from looking at the existing code, 2. would probably fit nicely?

sentrivana avatar Dec 02 '25 15:12 sentrivana