structlog
structlog copied to clipboard
CallSite Parameters first exception call stack
Is it possible to retain callsite params if exception is handled on higher level like general exception handler? Tried to override it manually, but it doesn't work.
def general_exception_handler(error: Exception):
traceback_exception = TracebackException.from_exception(exc)
filename = traceback_exception.stack[-1].filename
lineno = traceback_exception.stack[-1].lineno
func_name = traceback_exception.stack[-1].name
module = (traceback_exception.stack[-1].filename.removeprefix(getcwd()).lstrip(os.sep).
replace('.py', '').replace(os.sep, '.'))
logger: LoggerProtocol = get_logger(module)
logger.error(detail, extra=extra, lineno=lineno, func_name='test')
hi sorry for the delay – I'm not sure what exactly you'd like. Can you please give me a concrete example of what you need? thank you