Category: | Debugging |
Author/Contact Info | chromatic |
Description: | Based on tye's suggestion in (tye)Re: Automatic Debugging, this prints out the name of all subroutines called. It respects can and doesn't interfere with AUTOLOAD. It could easily be modified to call your own custom logger and to handle multiple modules in the use line.
I kinda like it, and I could be persuaded to put it up on the CPAN if it's well-received. You can test it out with the following code:
|
package Devel::TraceMethods; use strict; sub import { my ($package, $caller) = @_; my $src; { no strict 'refs'; $src = \%{$caller . '::'}; } foreach my $symbol (keys %$src) { my $sub; if (defined($sub = *{$src->{$symbol}}{CODE}) and (defined(&$sub))) { undef $src->{$symbol}; $src->{$symbol} = sub { logCall($symbol); return $sub->(@_); }; } } } sub logCall { print STDERR "Executing $_[0]!\n"; } 1; |
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: An Implementation of Devel::TraceMethods
by grinder (Bishop) on May 30, 2001 at 14:28 UTC | |
(tye)Re: An Implementation of Devel::TraceMethods
by tye (Sage) on May 30, 2001 at 18:56 UTC | |
Re: An Implementation of Devel::TraceMethods
by clemburg (Curate) on May 30, 2001 at 12:11 UTC |