line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::Middleware::LogWarn; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
1
|
|
|
1
|
|
43497
|
$Plack::Middleware::LogWarn::VERSION = '0.001002'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: converts to warns to log messages |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
51
|
|
9
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
26
|
|
10
|
1
|
|
|
1
|
|
8
|
use parent qw( Plack::Middleware ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
11
|
1
|
|
|
1
|
|
14185
|
use Plack::Util::Accessor qw( logger ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub call { |
14
|
2
|
|
|
2
|
1
|
61313
|
my($self, $env) = @_; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
local $SIG{__WARN__} = $self->logger || sub { |
17
|
1
|
|
|
1
|
|
33
|
$env->{'psgix.logger'}->({ |
18
|
|
|
|
|
|
|
level => 'warn', |
19
|
|
|
|
|
|
|
message => join '', @_ |
20
|
|
|
|
|
|
|
}); |
21
|
2
|
|
100
|
|
|
13
|
}; |
22
|
2
|
|
|
|
|
142
|
my $res = $self->app->($env); |
23
|
|
|
|
|
|
|
|
24
|
2
|
|
|
|
|
60
|
return $res; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
1; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=pod |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 NAME |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Plack::Middleware::LogWarn - converts to warns to log messages |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 VERSION |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
version 0.001002 |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 SYNOPSIS |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
builder { |
44
|
|
|
|
|
|
|
enable 'LogWarn'; |
45
|
|
|
|
|
|
|
$app; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# use it with another logger middleware |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
builder { |
51
|
|
|
|
|
|
|
enable 'LogWarn'; |
52
|
|
|
|
|
|
|
enable 'Log4perl', category => 'plack', conf => '/path/to/log4perl.conf'; |
53
|
|
|
|
|
|
|
$app; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 DESCRIPTION |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
LogWarn is a C component that will help you get warnings into |
59
|
|
|
|
|
|
|
a logger. You probably want to use some sort of real logging system such as |
60
|
|
|
|
|
|
|
L and another C such as L. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 CONFIGURATION |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=over 4 |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=item logger |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
optional, C that will capture warnings. By default it uses |
69
|
|
|
|
|
|
|
C<< $env->{'psgix.logger'} >> with a level of C. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=back |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 SEE ALSO |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
L |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 CREDITS |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Thanks to Micro Technology Services, Inc. for funding the initial development |
80
|
|
|
|
|
|
|
of this module and frew (Arthur Axel "fREW" Schmidt ) for his |
81
|
|
|
|
|
|
|
extensive patience and assistance. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 AUTHOR |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Geoffrey Darling |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
This software is copyright (c) 2011 by Geoffrey Darling. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
94
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
__END__ |