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
|
|
46974
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
45
|
|
5
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
72
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.003'; |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
366
|
use Log::Any; |
|
2
|
|
|
|
|
5814
|
|
|
2
|
|
|
|
|
12
|
|
10
|
2
|
|
|
2
|
|
739
|
use Log::Any::Plugin; |
|
2
|
|
|
|
|
28147
|
|
|
2
|
|
|
|
|
49
|
|
11
|
2
|
|
|
2
|
|
11
|
use Class::Load qw( is_class_loaded ); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
83
|
|
12
|
2
|
|
|
2
|
|
709
|
use Class::Method::Modifiers qw( install_modifier ); |
|
2
|
|
|
|
|
2043
|
|
|
2
|
|
|
|
|
334
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub import { |
15
|
2
|
|
|
2
|
|
14
|
my $class = shift; |
16
|
2
|
|
|
|
|
5
|
my $caller = caller; |
17
|
|
|
|
|
|
|
|
18
|
2
|
|
|
|
|
6
|
my $lite = is_class_loaded( 'Mojolicious::Lite' ); |
19
|
2
|
|
|
|
|
129
|
my $mojo = $caller->isa( 'Mojolicious' ); |
20
|
|
|
|
|
|
|
|
21
|
2
|
|
|
|
|
10
|
my $log = Log::Any->get_logger( |
22
|
|
|
|
|
|
|
default_adapter => 'MojoLog', |
23
|
|
|
|
|
|
|
category => $caller, |
24
|
|
|
|
|
|
|
@_, |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
2
|
|
|
|
|
4760
|
Log::Any::Plugin->add( 'History', size => 10 ); |
28
|
0
|
|
|
|
|
|
Log::Any::Plugin->add( 'Format' ); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# Manually inflate nulls, since we are not doing automatic assignment |
31
|
0
|
0
|
|
|
|
|
$log->inflate_nulls if $log->isa('Log::Any::Proxy::Null'); |
32
|
|
|
|
|
|
|
|
33
|
0
|
0
|
|
|
|
|
if ($lite) { |
|
|
0
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# Using Mojolicious::Lite |
35
|
|
|
|
|
|
|
|
36
|
0
|
0
|
|
|
|
|
return if $caller->app->log->isa('Log::Any::Proxy'); |
37
|
0
|
|
|
|
|
|
$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__ |