Delgan / loguru

Python logging made (stupidly) simple
MIT License
19.62k stars 695 forks source link

catpure exception as extras? #1138

Closed trim21 closed 4 months ago

trim21 commented 4 months ago

currently I'm using logger.exception to capture a exception, but it generate a very long {text} message.

Is it possible I capture exception with save feature but stored as extra field, instead of part of {text}?

Delgan commented 4 months ago

Do you mean when serialize=True? I plan to simplify things a bit, but for now, you would have to use a custom function.

trim21 commented 4 months ago

Thanks, I just read the code and I find that I don't need to custom anythink. It I consider .record.message as final logging message instead .text, then the exception traceback is already stored in a seprated text field.

trim21 commented 4 months ago

I re-open this becaust I find that .record.message doesn't support color, it store raw value <red>hello</red>,or not color for logger.opt(colors=True).info(...)....

trim21 commented 4 months ago

Nevermind, this is not a big problem