| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package FirePHP::Log4perl::Appender; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
224744
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
38
|
|
|
4
|
1
|
|
|
1
|
|
7
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
47
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
FirePHP::Log4perl::Appender |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
In your C<Log::Log4perl> config: |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
log4perl.rootLogger = DEBUG, FIREPHP |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
log4perl.appender.FIREPHP = FirePHP::Appender |
|
17
|
|
|
|
|
|
|
log4perl.appender.FIREPHP.layout = FirePHP::Layout |
|
18
|
|
|
|
|
|
|
log4perl.appender.FIREPHP.layout.ConversionPattern = [ %c ] %m |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
In the dispatcher of your application: |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $appender = first { $_->isa( 'FirePHP::Log4perl::Appender' ) } |
|
23
|
|
|
|
|
|
|
map{ $_->{appender} } values %{ Log::Log4perl->appenders() }; |
|
24
|
|
|
|
|
|
|
local $appender->{fire_php} = |
|
25
|
|
|
|
|
|
|
FirePHP::Dispatcher->new( $your_http_headers_compatile_object ); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# the normal dispatch stuff |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
$appender->fire_php->finalize; |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
This is a very simple appender for writing to a FirePHP console. |
|
34
|
|
|
|
|
|
|
Nontheless it is not easy to use because of scoping and threading |
|
35
|
|
|
|
|
|
|
issues because L<Log::Log4perl> normally just provides an application |
|
36
|
|
|
|
|
|
|
wide appender object that has no access whatsoever to the L<HTTP::Headers> |
|
37
|
|
|
|
|
|
|
object of the current object. Your best bet is to use a plugin that is |
|
38
|
|
|
|
|
|
|
spezialised for your framework. |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
|
41
|
|
|
|
|
|
|
|
|
42
|
1
|
|
|
1
|
|
7
|
use base qw/Log::Log4perl::Appender/; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
101
|
|
|
43
|
|
|
|
|
|
|
|
|
44
|
1
|
|
|
1
|
|
7
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
87
|
|
|
45
|
1
|
|
|
1
|
|
6
|
use Scalar::Util qw/looks_like_number blessed weaken/; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
65
|
|
|
46
|
1
|
|
|
1
|
|
540
|
use Data::Dump qw/dump/; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 METHODS |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head2 $class->new( %options ) |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
This creates a new, unassociated appender object. Most of the time |
|
53
|
|
|
|
|
|
|
you do not want to bind to a L<FirePHP::Dispatcher> object during |
|
54
|
|
|
|
|
|
|
creation but directly set (and un-set) it in the appropriate time |
|
55
|
|
|
|
|
|
|
during your application life-cycle. |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Returns: a new C<FirePHP::Log4perl::Appender> object |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub new { |
|
63
|
|
|
|
|
|
|
my $class = shift; |
|
64
|
|
|
|
|
|
|
my $self = bless { @_ }, $class; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 $self->fire_php |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Returns: the associated L<FirePHP::Dispatcher> or C<undef> |
|
71
|
|
|
|
|
|
|
if the appender is not bound to one |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub fire_php { |
|
76
|
|
|
|
|
|
|
my $self = shift; |
|
77
|
|
|
|
|
|
|
return $self->{fire_php}; |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 $self->log( %params ) |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Used by L<Log::Log4perl::Appender> to send messages |
|
84
|
|
|
|
|
|
|
to the FirePHP console |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub log { |
|
89
|
|
|
|
|
|
|
my ( $self, %p ) = @_; |
|
90
|
|
|
|
|
|
|
return unless $self->fire_php; |
|
91
|
|
|
|
|
|
|
$self->fire_php->send_headers( $p{message} ); |
|
92
|
|
|
|
|
|
|
return 1; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
__END__ |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
L<http://www.firephp.org>, L<Log::Log4perl>, L<FirePHP::Catalyst::Plugin> |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 AUTHOR |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Sebastian Willert, C<willert@cpan.org> |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Copyright 2009 by Sebastian Willert E<lt>willert@cpan.orgE<gt> |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
112
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=cut |
|
115
|
|
|
|
|
|
|
|