line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MojoX::Log::Any; |
2
|
|
|
|
|
|
|
# ABSTRACT: Use the current Log::Any adapter from Mojolicious |
3
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
48064
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
51
|
|
5
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
86
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.005'; |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
377
|
use Log::Any; |
|
2
|
|
|
|
|
5829
|
|
|
2
|
|
|
|
|
15
|
|
10
|
2
|
|
|
2
|
|
783
|
use Log::Any::Plugin; |
|
2
|
|
|
|
|
28235
|
|
|
2
|
|
|
|
|
56
|
|
11
|
2
|
|
|
2
|
|
15
|
use Class::Load qw( is_class_loaded ); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
72
|
|
12
|
2
|
|
|
2
|
|
740
|
use Class::Method::Modifiers qw( install_modifier ); |
|
2
|
|
|
|
|
2151
|
|
|
2
|
|
|
|
|
344
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub import { |
15
|
4
|
|
|
4
|
|
3841
|
my $class = shift; |
16
|
4
|
|
|
|
|
9
|
my $caller = caller; |
17
|
|
|
|
|
|
|
|
18
|
4
|
|
|
|
|
14
|
my $lite = is_class_loaded( 'Mojolicious::Lite' ); |
19
|
4
|
|
|
|
|
248
|
my $mojo = $caller->isa( 'Mojolicious' ); |
20
|
|
|
|
|
|
|
|
21
|
4
|
|
|
|
|
23
|
my $log = Log::Any->get_logger( |
22
|
|
|
|
|
|
|
default_adapter => 'MojoLog', |
23
|
|
|
|
|
|
|
category => $caller, |
24
|
|
|
|
|
|
|
@_, |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
4
|
|
|
|
|
4988
|
Log::Any::Plugin->add( 'History', size => 10 ); |
28
|
4
|
|
|
|
|
15180
|
Log::Any::Plugin->add( 'Format' ); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# Manually inflate nulls, since we are not doing automatic assignment |
31
|
4
|
100
|
|
|
|
9631
|
$log->inflate_nulls if $log->isa('Log::Any::Proxy::Null'); |
32
|
|
|
|
|
|
|
|
33
|
4
|
50
|
|
|
|
20
|
if ($lite) { |
|
|
0
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# Using Mojolicious::Lite |
35
|
|
|
|
|
|
|
|
36
|
4
|
100
|
|
|
|
23
|
return if $caller->app->log->isa('Log::Any::Proxy'); |
37
|
2
|
|
|
|
|
221
|
$caller->app->log( $log ); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
elsif ($mojo) { |
40
|
|
|
|
|
|
|
# Caller inherits from Mojolicious |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Entirely replace Mojolicious log method, so we return a reference to |
43
|
|
|
|
|
|
|
# the Log::Any proxy instead of to Mojo::Log |
44
|
|
|
|
|
|
|
install_modifier( $caller, 'around', log => sub { |
45
|
0
|
|
|
0
|
|
|
my $orig = shift; |
46
|
0
|
|
|
|
|
|
my $self = shift; |
47
|
|
|
|
|
|
|
|
48
|
0
|
0
|
|
|
|
|
$log = $_[1] if @_ > 1; |
49
|
0
|
|
|
|
|
|
return $log; |
50
|
0
|
|
|
|
|
|
}); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
__END__ |