| 1 | package Poet::Util::Debug; | ||||||||||||||||||||
| 2 | 8 | $Poet::Util::Debug::VERSION = '0.16'; | |||||||||||||||||||
| 3 | 8 | ▶ | use Carp qw(longmess); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 8 | ▶ | use Data::Dumper; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 8 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 8 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 8 | ▶ | use base qw(Exporter); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | our @EXPORT_OK = | ||||||||||||||||||||
| 10 | 8 | map { ( "$_", "$_" . "s", "$_" . "_live", "$_" . "s_live" ) } qw(dc dd dh dp); | |||||||||||||||||||
| 11 | 8 | our %EXPORT_TAGS = ( 'all' => \@EXPORT_OK ); | |||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 8 | my $console_log; | |||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 5 | ▶ | sub _dump_value_with_caller { | ||||||||||||||||||
|
Subroutine
_dump_value_with_caller: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 16 | 5 | my ( $value, $func_name ) = @_; | |||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | 5 | my $dump = | |||||||||||||||||||
| 19 | Data::Dumper->new( [$value] )->Indent(1)->Sortkeys(1)->Quotekeys(0)->Terse(1)->Dump(); | ||||||||||||||||||||
| 20 | 5 | my @caller = caller(1); | |||||||||||||||||||
| 21 | return | ||||||||||||||||||||
| 22 | 5 | sprintf( "[%s at %s line %d.] [%d] %s\n", $func_name, $caller[1], $caller[2], $$, $dump ); | |||||||||||||||||||
| 23 | } | ||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | 32 | ▶ | sub _define { | ||||||||||||||||||
|
Subroutine
_define: called CC=1 SCAR=0.2
| |||||||||||||||||||||
| 26 | 32 | my ( $func, $code ) = @_; | |||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 8 | ▶ | no strict 'refs'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 29 | 32 | my $funcs = $func . "s"; | |||||||||||||||||||
| 30 | 32 | my $func_live = $func . "_live"; | |||||||||||||||||||
| 31 | 32 | my $funcs_live = $func . "s_live"; | |||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | 4 | ▶ | *$func = sub { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
| |||||||||||||||||||||
| 34 | 4 | ▶ | return unless Poet::Environment->current_env->conf->is_development; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 35 | 4 | $code->( _dump_value_with_caller( $_[0], $func ) ); | |||||||||||||||||||
| 36 | 32 | }; | |||||||||||||||||||
| 37 | 0 | ▶ | *$funcs = sub { | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 38 | 0 | ▶ | return unless Poet::Environment->current_env->conf->is_development; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 39 | 0 | $code->( longmess( _dump_value_with_caller( $_[0], $funcs ) ) ); | |||||||||||||||||||
| 40 | 32 | }; | |||||||||||||||||||
| 41 | 1 | ▶ | *$func_live = sub { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 42 | 1 | $code->( _dump_value_with_caller( $_[0], $func_live ) ); | |||||||||||||||||||
| 43 | 32 | }; | |||||||||||||||||||
| 44 | 0 | ▶ | *$funcs_live = sub { | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 45 | 0 | $code->( longmess( _dump_value_with_caller( $_[0], $funcs_live ) ) ); | |||||||||||||||||||
| 46 | 32 | }; | |||||||||||||||||||
| 47 | } | ||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | _define( | ||||||||||||||||||||
| 50 | 'dc', | ||||||||||||||||||||
| 51 | 1 | ▶ | sub { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
| |||||||||||||||||||||
| 52 | 1 | ▶ | $console_log ||= Poet::Environment->current_env->logs_path("console.log"); | ||||||||||||||||||
|
Condition33%1/3
$console_log ||= "Poet::Environment"->current_env->logs_path("console.log")
MC/DC0%0/2
$console_log ||= "Poet::Environment"->current_env->logs_path("console.log")
$console_log
"Poet::Environment"->current_env->logs_path("console.log")
Truth table33%1/3
A ||= B
A= $console_logB= "Poet::Environment"->current_env->logs_path("console.log")
| |||||||||||||||||||||
| 53 | 1 | open( my $fh, ">>", $console_log ); | |||||||||||||||||||
| 54 | 1 | $fh->print( $_[0] ); | |||||||||||||||||||
| 55 | } | ||||||||||||||||||||
| 56 | 8 | ); | |||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | _define( | ||||||||||||||||||||
| 59 | 'dd', | ||||||||||||||||||||
| 60 | 1 | ▶ | sub { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 61 | 1 | die $_[0]; | |||||||||||||||||||
| 62 | } | ||||||||||||||||||||
| 63 | 8 | ); | |||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | _define( | ||||||||||||||||||||
| 66 | 'dh', | ||||||||||||||||||||
| 67 | 2 | ▶ | sub { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 68 | 2 | return "<pre>\n$_[0]</pre>\n"; | |||||||||||||||||||
| 69 | } | ||||||||||||||||||||
| 70 | 8 | ); | |||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | _define( | ||||||||||||||||||||
| 73 | 'dp', | ||||||||||||||||||||
| 74 | 1 | ▶ | sub { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 75 | 1 | print STDERR $_[0]; | |||||||||||||||||||
| 76 | } | ||||||||||||||||||||
| 77 | 8 | ); | |||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | 8 | 1; | |||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | __END__ | ||||||||||||||||||||