in reply to catch errors within C
There are many places that are going to write directly to the *STDERR handle via the C-side Perl_debug_log variable. In all places I've noticed this goes through PerlIO. I think you can add a layer to the variable. I've never actually tried this but I'd just recommend checking out perlio and PerlIO::via. It looks like it'd be fairly easy to make a wrapper that'd just write to some alternate location.
⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊
In Section
Seekers of Perl Wisdom