I've recently found the need to unravel, debug, and refactor old code that breaks almost every rule in the book (think "Perl Worst Practices" ;). This has presented "interesting" challenges, particularly the need to understand the source of symbols spewed into the main namespace from all manner of careless EXPORTs.
One of the things I want to do is have a running trace (in Apache logs, for example) of subroutine calls with their fully-qualified names. I want to do more than print sub names, however. I want to wrap them using Hook::LexWrap to provide general flexibility for inspecting a multitude of conditions surrounding each call (H::L allows you to install pre- and post- wrappers for subs while preserving the expected behavior of caller()).
I looked in the Devel:: namespace and found some modules that do similar things. However, none of them seem to do exactly what I want:
Toward this end, I'm creating a module, Devel::WrapExports, that behaves as explained above. If, for example, I am facing a monster CGI that 'use's twenty libraries, each of which forcefully exports all kinds of symbols, I can simply say 'use Devel::WrapExports' at the top of the CGI and cause each subroutine that has been (perhaps inadvertently) imported into the CGI to be wrapped with default pre- and post-wrappers to trace entry and exit. I can pass my own callbacks to 'use' and they will be installed as wrappers to do all manner of custom tracing, logging, etc.
I'd like to share the module on CPAN, but I wanted to ask first -- there are lots of Devel:: modules that do tracing, so I don't want to commit my own form of namespace pollution by adding a duplicate. Have I overlooked an existing module that provides the functionality I've described, or have I come up with something novel?
Thanks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: [RFC: Module proposal] Tracing sneaky EXPORTs using wrappers
by lodin (Hermit) on Apr 10, 2008 at 16:57 UTC | |
by krazyk (Beadle) on Apr 11, 2008 at 18:21 UTC | |
by lodin (Hermit) on Apr 12, 2008 at 01:09 UTC | |
by krazyk (Beadle) on Apr 16, 2008 at 05:36 UTC |