line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::HTTP::Spore::Role::Debug; |
2
|
|
|
|
|
|
|
$Net::HTTP::Spore::Role::Debug::VERSION = '0.09'; |
3
|
22
|
|
|
22
|
|
75477
|
use IO::File; |
|
22
|
|
|
|
|
58
|
|
|
22
|
|
|
|
|
3838
|
|
4
|
22
|
|
|
22
|
|
151
|
use Moose::Role; |
|
22
|
|
|
|
|
42
|
|
|
22
|
|
|
|
|
197
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
has trace => ( |
7
|
|
|
|
|
|
|
is => 'rw', |
8
|
|
|
|
|
|
|
isa => 'Str', |
9
|
|
|
|
|
|
|
predicate => 'has_trace', |
10
|
|
|
|
|
|
|
clearer => 'reset_trace', |
11
|
|
|
|
|
|
|
); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has _trace_fh => ( |
14
|
|
|
|
|
|
|
is => 'rw', |
15
|
|
|
|
|
|
|
isa => 'GLOB', |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub BUILD { |
19
|
33
|
|
|
33
|
0
|
325060
|
my ($self, $args) = @_; |
20
|
33
|
|
|
|
|
113
|
my $trace; |
21
|
|
|
|
|
|
|
|
22
|
33
|
100
|
|
|
|
157
|
$trace = $args->{trace} if $args->{trace}; |
23
|
33
|
50
|
|
|
|
159
|
$trace = $ENV{SPORE_TRACE} if defined $ENV{SPORE_TRACE}; |
24
|
|
|
|
|
|
|
|
25
|
33
|
100
|
|
|
|
127
|
if (!defined $trace){ |
26
|
32
|
|
|
|
|
1409
|
$self->reset_trace; |
27
|
32
|
|
|
|
|
107
|
return; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
1
|
|
|
|
|
3
|
my ($level, $fh); |
31
|
1
|
50
|
|
|
|
7
|
if ( $trace =~ /(\d)=(.+)$/ ) { |
32
|
1
|
|
|
|
|
3
|
$level = $1; |
33
|
1
|
|
|
|
|
3
|
my $file = $2; |
34
|
1
|
50
|
|
|
|
8
|
$fh = IO::File->new( $file, 'w' ) |
35
|
|
|
|
|
|
|
or die "Cannot open trace file $file"; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
else { |
38
|
0
|
|
|
|
|
0
|
$level = $trace; |
39
|
0
|
0
|
|
|
|
0
|
$fh = IO::File->new('>&STDERR') |
40
|
|
|
|
|
|
|
or die('Duplication of STDERR for debug output failed (perhaps your STDERR is closed?)'); |
41
|
|
|
|
|
|
|
} |
42
|
1
|
|
|
|
|
129
|
$fh->autoflush; |
43
|
1
|
|
|
|
|
100
|
$self->_trace_fh($fh); |
44
|
1
|
|
|
|
|
33
|
$self->trace($level); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub _trace_msg { |
48
|
41
|
|
|
41
|
|
92
|
my $self = shift; |
49
|
41
|
|
|
|
|
81
|
my $template = shift; |
50
|
41
|
100
|
|
|
|
1631
|
return unless $self->has_trace; |
51
|
|
|
|
|
|
|
|
52
|
1
|
|
|
|
|
28
|
my $fh = $self->_trace_fh(); |
53
|
1
|
|
|
|
|
47
|
print $fh (sprintf( $template, @_ )."\n"); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _trace_verbose { |
57
|
0
|
|
|
0
|
|
|
my $self = shift; |
58
|
0
|
0
|
0
|
|
|
|
return unless $self->trace && $self->trace > 1; |
59
|
0
|
|
|
|
|
|
$self->_trace_msg(@_); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=pod |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=encoding UTF-8 |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 NAME |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Net::HTTP::Spore::Role::Debug |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 VERSION |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
version 0.09 |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 AUTHORS |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=over 4 |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item * |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Franck Cuny <franck.cuny@gmail.com> |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item * |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Ash Berlin <ash@cpan.org> |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=item * |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Ahmad Fatoum <athreef@cpan.org> |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=back |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
This software is copyright (c) 2012 by Linkfluence. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
101
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=cut |