-
-
09 Jul 2005 21:37:26 UTC
- Distribution: Devel-TraceMethods
- Module version: 1.00
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Issues (1)
- Testers (832 / 0 / 0)
- Kwalitee
Bus factor: 1- 89.61% Coverage
- License: perl_5
- Activity
24 month- Tools
- Download (4.92KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- unknown
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
Devel::TraceMethods - Perl module for tracing module calls
SYNOPSIS
use Devel::TraceMethods qw( PackageOne PackageTwo );
DESCRIPTION
Devel::TraceMethods allows you to attach a logging subroutine of your choosing to all of the methods and functions within multiple packages or classes. You can use this to trace execution. It even respects inheritance.
To enable logging, pass the name of the packages you wish to trace on the line where you use Devel::TraceMethods. It will automatically install logging for all functions in the named packages.
You can also call
import()
after you haveuse()
d the module if you want to log functions and methods in another package.You can specify per-package (or per-class) logging subroutines. For example:
Devel::TraceMethods( SomePackage => \&log_one, OtherPackage => \&log_two );
callback( $subroutine_reference )
By default, Devel::TraceMethods uses
Carp::carp()
to log a method call. You can change this with theset_logger()
function. Pass a subroutine reference as the only argument, and all subsequent calls to logged methods will use the new subroutine reference instead ofcarp()
.The first argument to the logging subroutine is the full name of the logged method. The rest of the arguments are copies of those being passed to the logged method. You can modify them in the logging subroutine without disturbing your call.
TODO
- Unlog packages.
- Attach to calling package if nothing is specified in @_? Something like:
-
push @_, scalar caller() unless @_;
- Attach only to specified methods.
- Add ability to disable logging on certain methods.
- Allow multiple logging subs.
- Allow per-method logging sub?
- Don't copy other slots of typeglob? (Could be tricky, an internals wizard will have to look at this.)
COPYRIGHT and AUTHOR
Copyright (c) 2001, 2005 chromatic
chromatic at wgz dot org
.Thanks to Tye McQueen for the initial suggestion, grinder at Perl Monks for the callback suggestion, and Podmaster for a suggestion on enhancing the default logging subroutine
SEE ALSO
perl(1).
Module Install Instructions
To install Devel::TraceMethods, copy and paste the appropriate command in to your terminal.
cpanm Devel::TraceMethods
perl -MCPAN -e shell install Devel::TraceMethods
For more information on module installation, please visit the detailed CPAN module installation guide.