You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{"timestamp": "2024-10-06 21:15:27", "level": "ERROR", "message": "An error has been caught in function '<module>', process 'MainProcess' (5572), thread 'MainThread' (7948):"}
Traceback (most recent call last):
> File "D:\User\Dropbox\Python\test\test3.py", line 34, in <module>
error()
└ <function error at 0x000001FF66294EA0>
File "D:\User\Dropbox\Python\test\test3.py", line 32, in error
z = x / y
│ └ 0
└ 10
ZeroDivisionError: division by zero
How to include
Traceback (most recent call last):
> File "D:\User\Dropbox\Python\test\test3.py", line 34, in <module>
error()
└ <function error at 0x000001FF66294EA0>
File "D:\User\Dropbox\Python\test\test3.py", line 32, in error
z = x / y
│ └ 0
└ 10
ZeroDivisionError: division by zero
to JSON?
The text was updated successfully, but these errors were encountered:
I find serialization unhelpful without tracebacks, so I took a similar approach to @sky-py. I checked out better_exception (thanks @Delgan) and ended up serializing the tracebacks (as list[dict[...]]).
While this works, the need for patch makes it awkward. It means I need a global logger = loguru_logger.patch(...) and to from myapp.core import logger. It's a little bit of unnecessary coupling.
It's not a big deal, just something I felt worth pointing out. I did add a way to limit the traceback depth (for serialized and non-serialized), per logging statement, which is actually pretty helpful.
@dmyersturnbull Can you use the patcher attribute of the logger.configure() method maybe?
That would patch the logger globally, avoiding the need for a custom from myapp.core import logger import.
Is there any way to add loguru's beautiful traceback (like that when adding
backtrace=True, diagnose=True
to log) to CUSTOM JSON log?For example for
getting:
How to include
to JSON?
The text was updated successfully, but these errors were encountered: