structlog icon indicating copy to clipboard operation
structlog copied to clipboard

CallSite Parameters first exception call stack

Open Forceres opened this issue 1 year ago • 1 comments

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')

Forceres avatar Sep 25 '24 02:09 Forceres

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

hynek avatar Jan 13 '25 08:01 hynek