NAME
MooseX::Role::Debugger - Automatically add debugging output with a role
SYNOPSIS
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 = [
...
]
DESCRIPTION
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.
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
).
USAGE
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 '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:
- debug
-
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.
- logger
-
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 candebug()
things. - skip_methods
-
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: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.
- skip_attrs
-
Attributes are skipped over automatically. Attributes that have explicit (and differently-named) accessors or mutators (via the
reader
orwriter
bits) are handled properly. Set this to something false to turn this behaviour off.
AUTHOR
Dave Houston <dhouston@cpan.org>
SPONSORED BY
Ionzero, LLC http://ionzero.com/
SEE ALSO
Log::Dispatch, Moose, MooseX::Role::Parameterized
BUGS
Probably
LICENSE
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.