MooseX::Role::Debugger - Automatically add debugging output with a role
package SomeMooseClass; use Moose; with 'MooseX::Role::Debugger'; sub foo { ... } __PACKAGE__->meta->make_immutable;
..and later..
$some_moose_class->foo();
..you get some output..
foo called with parameters: $VAR1 = [ ... ] (whatever foo may have done) foo returned: $VAR1 = [ ... ]
This role is intended to add to any Moose class. It will do a bit of introspection on the consuming class and wrap each one in an around modifier and add some debugging output before and after.
around
By default, logging is done via a Log::Dispatch object (generated in the role), with both the 'Screen' and 'File' outputs (the 'File' output uses a filename debug.log).
debug.log
MooseX::Role::Debugger makes use of parameterized roles, so you may pass some extra information to your role in the with statement. The syntax is fairly straightforward:
with
with 'MooseX::Role::Debugger' => { debug => 1, logger => $log_obj };
Though the defaults are fairly sensible. If you feel the need to contradict me and supply your own options, they are:
A boolean indicating if you want to see debug output or not. If this is what Perl considers a true value, you get all sorts of extra stuff. If it is false, there is no extra overhead.
This is generated in the role by default, and is a Log::Dispatch object. If you'd like to provide different options for your logging, do it here. All debugging is done by calling the debug method on this object. Make sure anything you replace this with can debug() things.
debug
debug()
This is an array reference containing the names of any methods you'd like to skip when adding debugging. The list is obtained by querying the method names from <Moose::Object-meta>>. At the time, this is:
<Moose::Object-
dump BUILDALL DESTROY DEMOLISHALL meta BUILDARGS does new DOES can
If you provide an alternate list, please be aware that you should also include these items. Were I you, I wouldn't worry about changing it at all.
Attributes are skipped over automatically. Attributes that have explicit (and differently-named) accessors or mutators (via the reader or writer bits) are handled properly. Set this to something false to turn this behaviour off.
reader
writer
Dave Houston <dhouston@cpan.org>
Ionzero, LLC http://ionzero.com/
Log::Dispatch, Moose, MooseX::Role::Parameterized
Probably
Copyright (C) 2011, Dave Houston <dhouston@cpan.org>
This library is free software; you can redistribute and/or modify it under the same terms as Perl itself.
To install MooseX::Role::Debugger, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooseX::Role::Debugger
CPAN shell
perl -MCPAN -e shell install MooseX::Role::Debugger
For more information on module installation, please visit the detailed CPAN module installation guide.