| 1 | package Dancer::Plugin::DebugDump; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | 2 | ▶ | use Dancer::Logger; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | 2 | ▶ | use Dancer::Plugin; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | 2 | ▶ | use Data::Dump; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 8 | |||||||||||||||
| 9 | 2 | our $VERSION = '0.03'; | |||||||||||||
| 10 | |||||||||||||||
| 11 | 2 | Dancer::Logger::warning( | |||||||||||||
| 12 | "Dancer::Plugin::DebugDump is deprecated and may go away in future.\n", | ||||||||||||||
| 13 | "Dancer's built in debug() keyword automatically serialises for you.\n", | ||||||||||||||
| 14 | ); | ||||||||||||||
| 15 | |||||||||||||||
| 16 | 0 | ▶ | register debug_dump => sub { | ||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||||
| 17 | 0 | my $message; | |||||||||||||
| 18 | 0 | ▶ | if (@_ == 1) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 19 | # Single thing to dump, easy: | ||||||||||||||
| 20 | 0 | Dancer::Logger::debug( Data::Dump::dump(shift) ); | |||||||||||||
| 21 | } elsif (@_ % 2 == 0) { | ||||||||||||||
| 22 | # Looks like we got pairs of labels and dumpable things: | ||||||||||||||
| 23 | 0 | ▶ | while (@_) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 24 | 0 | my ($label, $ref) = splice @_, 0, 2; | |||||||||||||
| 25 | 0 | Dancer::Logger::debug( "$label: " . Data::Dump::dump($ref) ); | |||||||||||||
| 26 | } | ||||||||||||||
| 27 | } else { | ||||||||||||||
| 28 | # Just feed each argument to dump() and log the result | ||||||||||||||
| 29 | 0 | Dancer::Logger::debug(Data::Dump::dump($_)) for @_; | |||||||||||||
| 30 | } | ||||||||||||||
| 31 | 2 | }; | |||||||||||||
| 32 | |||||||||||||||
| 33 | 2 | register_plugin; | |||||||||||||
| 34 | |||||||||||||||
| 35 | =head1 NAME | ||||||||||||||
| 36 | |||||||||||||||
| 37 | Dancer::Plugin::DebugDump - dump objects to debug log with Data::Dump [DEPRECATED] | ||||||||||||||
| 38 | |||||||||||||||
| 39 | =head1 DEPRECATION NOTICE | ||||||||||||||
| 40 | |||||||||||||||
| 41 | *NOTE* : this module is now deprecated; there's no need for it, as Dancer's own | ||||||||||||||
| 42 | L<debug keyword|Dancer/debug> automatically serialises any references passed to | ||||||||||||||
| 43 | it using L<Data::Dumper>, so you can just say e.g.: | ||||||||||||||
| 44 | |||||||||||||||
| 45 | debug \%foo; | ||||||||||||||
| 46 | |||||||||||||||
| 47 | or | ||||||||||||||
| 48 | |||||||||||||||
| 49 | debug "User details", \%foo; | ||||||||||||||
| 50 | |||||||||||||||
| 51 | This plugin may be removed from CPAN at some point in the future; I've decided | ||||||||||||||
| 52 | to leave it around with a deprecation notice for the time being so that it's | ||||||||||||||
| 53 | still available for anyone already using it. | ||||||||||||||
| 54 | |||||||||||||||
| 55 | |||||||||||||||
| 56 | =head1 DESCRIPTION | ||||||||||||||
| 57 | |||||||||||||||
| 58 | Provides a C<debug_dump> keyword, which takes an optional label and an object | ||||||||||||||
| 59 | or reference to dump, and calls Dancer's C<debug> keyword after dumping the | ||||||||||||||
| 60 | object / reference with L<Data::Dump>. | ||||||||||||||
| 61 | |||||||||||||||
| 62 | Allows quick and easy debugging by dumping stuff to your log/console. | ||||||||||||||
| 63 | |||||||||||||||
| 64 | |||||||||||||||
| 65 | =cut | ||||||||||||||
| 66 | |||||||||||||||
| 67 | |||||||||||||||
| 68 | =head1 SYNOPSIS | ||||||||||||||
| 69 | |||||||||||||||
| 70 | use Dancer::Plugin::DebugDump; | ||||||||||||||
| 71 | |||||||||||||||
| 72 | debug_dump("My nice object" => $object); | ||||||||||||||
| 73 | debug_dump("My hash" => \%hash); | ||||||||||||||
| 74 | debug_dump($anotherref); | ||||||||||||||
| 75 | |||||||||||||||
| 76 | =head1 AUTHOR | ||||||||||||||
| 77 | |||||||||||||||
| 78 | David Precious, C<< <davidp at preshweb.co.uk> >> | ||||||||||||||
| 79 | |||||||||||||||
| 80 | =head1 BUGS | ||||||||||||||
| 81 | |||||||||||||||
| 82 | Please report any bugs or feature requests to C<bug-dancer-plugin-debugdump at rt.cpan.org>, or through | ||||||||||||||
| 83 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Dancer-Plugin-DebugDump>. I will be notified, and then you'll | ||||||||||||||
| 84 | automatically be notified of progress on your bug as I make changes. | ||||||||||||||
| 85 | |||||||||||||||
| 86 | |||||||||||||||
| 87 | |||||||||||||||
| 88 | |||||||||||||||
| 89 | =head1 SUPPORT | ||||||||||||||
| 90 | |||||||||||||||
| 91 | You can find documentation for this module with the perldoc command. | ||||||||||||||
| 92 | |||||||||||||||
| 93 | perldoc Dancer::Plugin::DebugDump | ||||||||||||||
| 94 | |||||||||||||||
| 95 | |||||||||||||||
| 96 | You can also look for information at: | ||||||||||||||
| 97 | |||||||||||||||
| 98 | =over 4 | ||||||||||||||
| 99 | |||||||||||||||
| 100 | =item * RT: CPAN's request tracker | ||||||||||||||
| 101 | |||||||||||||||
| 102 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Dancer-Plugin-DebugDump> | ||||||||||||||
| 103 | |||||||||||||||
| 104 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||||||
| 105 | |||||||||||||||
| 106 | L<http://annocpan.org/dist/Dancer-Plugin-DebugDump> | ||||||||||||||
| 107 | |||||||||||||||
| 108 | =item * CPAN Ratings | ||||||||||||||
| 109 | |||||||||||||||
| 110 | L<http://cpanratings.perl.org/d/Dancer-Plugin-DebugDump> | ||||||||||||||
| 111 | |||||||||||||||
| 112 | =item * Search CPAN | ||||||||||||||
| 113 | |||||||||||||||
| 114 | L<http://search.cpan.org/dist/Dancer-Plugin-DebugDump/> | ||||||||||||||
| 115 | |||||||||||||||
| 116 | =back | ||||||||||||||
| 117 | |||||||||||||||
| 118 | |||||||||||||||
| 119 | =head1 ACKNOWLEDGEMENTS | ||||||||||||||
| 120 | |||||||||||||||
| 121 | |||||||||||||||
| 122 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||
| 123 | |||||||||||||||
| 124 | Copyright 2010 David Precious. | ||||||||||||||
| 125 | |||||||||||||||
| 126 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||
| 127 | under the terms of either: the GNU General Public License as published | ||||||||||||||
| 128 | by the Free Software Foundation; or the Artistic License. | ||||||||||||||
| 129 | |||||||||||||||
| 130 | See http://dev.perl.org/licenses/ for more information. | ||||||||||||||
| 131 | |||||||||||||||
| 132 | |||||||||||||||
| 133 | =cut | ||||||||||||||
| 134 | |||||||||||||||
| 135 | 2 | 1; # End of Dancer::Plugin::DebugDump | |||||||||||||