stackprinter icon indicating copy to clipboard operation
stackprinter copied to clipboard

Add a way to preprocess variables before printing

Open mmev opened this issue 6 months ago • 1 comments

Hi there,

I've encountered the issue already mentioned in https://github.com/cknd/stackprinter/issues/50. Current implementation doesn’t let me fully hide sensitive data from the logs (dict variables, class representation string, etc).

I'd like to propose adding an optional keyword argument to the show, format, and format_current_stack methods that accepts a Callable. This function would receive each variable as it's being processed, allowing users to apply transformation before it's printed to the console. That way, any custom types can be handled as well.

I'd be happy to work on a PR for this if that's okay with you.

mmev avatar Jul 05 '25 17:07 mmev

Hi there! Thank you, this sounds like a very good idea, and a nice small PR would be welcome of course

cknd avatar Jul 05 '25 20:07 cknd