Open Jakobovski opened 2 months ago
Hey @Jakobovski.
When format
is a str
, Loguru automatically appends "\n{exception}"
to the format for convenience.
You can disable this by using a formatting function instead of a string:
logger.add(sys.stdout, format=lambda r: "{extra[serialized]}")
I am trying to log with a custom JSON serialization and include the traceback and exception details in the JSON. I used
patch()
in order to do this.Unexpectedly, unless i add the following line
record['exception'] = None
topatching()
loguru will log the traceback in a non-JSON format even though I am usingformat="{extra[serialized]}"
See the code below
Am i doing something wrong or is this a bug?