Adam Flott > Thorium > Thorium::Roles::Trace

Download:
Thorium-0.510.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  1
View/Report Bugs
Module Version: 0.510   Source  

NAME ^

Thorium::Roles::Trace - Add code tracing and argument dumping to your class

VERSION ^

version 0.510

SYNOPSIS ^

    package MyModule;
    
    use Moose;
    with qw(Thorium::Roles::Trace);
    
    # ... methods, attributes and such

Then when using an object of your class

    use MyModule;
    
    # new object, with tracing turned on
    
    my $obj = MyModule->new(tacing => 1);
    
    $obj->method(); # method and all calls from $self interally are traced
    # ##### Entering MyModule::method #####
    # ##### Leaving MyModule::method #####
    
    $obj->dump_args_in(1);
    
    $obj->method2({one => 1}); # dump arguments being passed into methods
    # ##### Entering MyModule::method2 #####
    # *** method2 args ***
    # $VAR1 = [                    
    #           {
    #             'one' => 1
    #           }
    #         ];
    # ##### Leaving MyModule::method2 #####

Note that methods added after tracing is set will not be logged until tracing is set again. Methods set with *MyModule::method = sub {} will never be seen; use $meta-add_method> instead!

DESCRIPTION ^

This role adds tracing to arguments, sub-routines entering/leaving and returned data to Thorium::Log logging or STDERR if no logging sub-system found.

WARNING! ^

Do not keep tracing enabled in production. It has measurable performance penalties! Tracing should be a temporary debugging action. Proper logging is a permanent debugging action.

MORE WARNING! ^

Once you turn on tracing it is not possible to turn off as the original references to the sub-routines are embedded into new sub-routines and as a result, lost. It is technically possible add the ability to turn off tracing, but for the sake of simplicity and for the note listed in "WARNING!" the feature is absent.

ATTRIBUTES ^

Optional Attributes

PUBLIC API METHODS ^

None. This is a Moose::Role.

AUTHOR ^

Adam Flott <adam@npjh.com>

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2011 by Adam Flott <adam@npjh.com>, CIDC.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

syntax highlighting: