| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Akamai::Open::Debug; |
|
2
|
|
|
|
|
|
|
BEGIN { |
|
3
|
1
|
|
|
1
|
|
22779
|
$Akamai::Open::Debug::AUTHORITY = 'cpan:PROBST'; |
|
4
|
|
|
|
|
|
|
} |
|
5
|
|
|
|
|
|
|
# ABSTRACT: Debugging interface for the Akamai Open API Perl clients |
|
6
|
|
|
|
|
|
|
$Akamai::Open::Debug::VERSION = '0.03'; |
|
7
|
1
|
|
|
1
|
|
9
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
33
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
41
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
480
|
use MooseX::Singleton; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use Data::Dumper qw/Dumper/; |
|
12
|
|
|
|
|
|
|
use Log::Log4perl; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $default_conf = q/ |
|
15
|
|
|
|
|
|
|
log4perl.category.Akamai.Open.Debug = ERROR, Screen |
|
16
|
|
|
|
|
|
|
log4perl.appender.Screen = Log::Log4perl::Appender::Screen |
|
17
|
|
|
|
|
|
|
log4perl.appender.Screen.stderr = 1 |
|
18
|
|
|
|
|
|
|
log4perl.appender.Screen.layout = Log::Log4perl::Layout::PatternLayout |
|
19
|
|
|
|
|
|
|
log4perl.appender.Screen.layout.ConversionPattern = %p - %C - %m%n |
|
20
|
|
|
|
|
|
|
/; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has 'config' => (is => 'rw'); |
|
23
|
|
|
|
|
|
|
has 'logger' => (is => 'rw', default => sub{return(Log::Log4perl::get_logger('Akamai::Open::Debug'));}); |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# is called after Moose has builded the object |
|
26
|
|
|
|
|
|
|
sub BUILD { |
|
27
|
|
|
|
|
|
|
my $self = shift; |
|
28
|
|
|
|
|
|
|
$self->config($default_conf) unless($self->config); |
|
29
|
|
|
|
|
|
|
Log::Log4perl::init_once(\$self->config); |
|
30
|
|
|
|
|
|
|
return; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub dump_obj { |
|
34
|
|
|
|
|
|
|
my $self = shift; |
|
35
|
|
|
|
|
|
|
my $ref = shift; |
|
36
|
|
|
|
|
|
|
$self->logger->info('Dumping object: ', Dumper($ref)); |
|
37
|
|
|
|
|
|
|
return; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub debugger { |
|
41
|
|
|
|
|
|
|
my $self = shift; |
|
42
|
|
|
|
|
|
|
my $new = shift; |
|
43
|
|
|
|
|
|
|
my $prev = shift; |
|
44
|
|
|
|
|
|
|
my $sub = (caller(1))[3]; |
|
45
|
|
|
|
|
|
|
$self->debug->logger->debug(sprintf('setting %s to %s (%s before)', $sub, $new, $prev ? $prev : 'undef')); |
|
46
|
|
|
|
|
|
|
return; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__END__ |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=pod |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=encoding utf-8 |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 NAME |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Akamai::Open::Debug - Debugging interface for the Akamai Open API Perl clients |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 VERSION |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
version 0.03 |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
use Akamai::Open::Debug; |
|
68
|
|
|
|
|
|
|
use Akamai::Open::Client; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
my $log_conf = q/ |
|
71
|
|
|
|
|
|
|
log4perl.category.Akamai.Open.Debug = DEBUG, Screen |
|
72
|
|
|
|
|
|
|
log4perl.appender.Screen = Log::Log4perl::Appender::Screen |
|
73
|
|
|
|
|
|
|
log4perl.appender.Screen.stderr = 1 |
|
74
|
|
|
|
|
|
|
log4perl.appender.Screen.layout = Log::Log4perl::Layout::PatternLayout |
|
75
|
|
|
|
|
|
|
log4perl.appender.Screen.layout.ConversionPattern = %p - %C - %m%n |
|
76
|
|
|
|
|
|
|
/; |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
my $debug = Akamai::Open::Debug->initialize(config => $log_conf); |
|
79
|
|
|
|
|
|
|
my $client = Akamai::Open::Client->new(debug => $debug); |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
I<Akamai::Open::Debug> uses L<Log::Log4perl|http://search.cpan.org/perldoc?Log::Log4perl> for logging purposes and thus is |
|
82
|
|
|
|
|
|
|
very flexible and easy configurable. |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 ABOUT |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
I<Akamai::Open::Debug> provides the debugging and logging functionality |
|
87
|
|
|
|
|
|
|
for the I<Akamai::Open> API client and uses uses L<MooseX::Singleton|http://search.cpan.org/perldoc?MooseX::Singleton> |
|
88
|
|
|
|
|
|
|
to provide a single instance based logging solution. |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 USAGE |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
If you want to configure your own logging, just initialize your |
|
93
|
|
|
|
|
|
|
L<Akamai::Open> API client, with an I<Akamai::Open::Debug> object. |
|
94
|
|
|
|
|
|
|
To do this, instantiate an object with your own I<Log::Log4perl> |
|
95
|
|
|
|
|
|
|
configuration (see I<Log::Log4perl> for example configurations): |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
my $debug = Akamai::Open::Debug->initialize(config => $log_conf); |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
The only thing you've to consider is, that the I<Log::Log4perl> category |
|
100
|
|
|
|
|
|
|
has to be named I<log4perl.category.Akamai.Open.Debug>, as written in |
|
101
|
|
|
|
|
|
|
the example. |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
After that you can pass your object to your client: |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
my $client = Akamai::Open::Client->new(debug => $debug); |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 AUTHOR |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Martin Probst <internet+cpan@megamaddin.org> |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
This software is copyright (c) 2014 by Martin Probst. |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
116
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=cut |