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
|
|
47144
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
47
|
|
5
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
77
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.004'; |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
373
|
use Log::Any; |
|
2
|
|
|
|
|
5941
|
|
|
2
|
|
|
|
|
13
|
|
10
|
2
|
|
|
2
|
|
767
|
use Log::Any::Plugin; |
|
2
|
|
|
|
|
28937
|
|
|
2
|
|
|
|
|
57
|
|
11
|
2
|
|
|
2
|
|
14
|
use Class::Load qw( is_class_loaded ); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
75
|
|
12
|
2
|
|
|
2
|
|
736
|
use Class::Method::Modifiers qw( install_modifier ); |
|
2
|
|
|
|
|
2129
|
|
|
2
|
|
|
|
|
344
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub import { |
15
|
4
|
|
|
4
|
|
3850
|
my $class = shift; |
16
|
4
|
|
|
|
|
9
|
my $caller = caller; |
17
|
|
|
|
|
|
|
|
18
|
4
|
|
|
|
|
14
|
my $lite = is_class_loaded( 'Mojolicious::Lite' ); |
19
|
4
|
|
|
|
|
240
|
my $mojo = $caller->isa( 'Mojolicious' ); |
20
|
|
|
|
|
|
|
|
21
|
4
|
|
|
|
|
22
|
my $log = Log::Any->get_logger( |
22
|
|
|
|
|
|
|
default_adapter => 'MojoLog', |
23
|
|
|
|
|
|
|
category => $caller, |
24
|
|
|
|
|
|
|
@_, |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
4
|
|
|
|
|
5046
|
Log::Any::Plugin->add( 'History', size => 10 ); |
28
|
4
|
|
|
|
|
14530
|
Log::Any::Plugin->add( 'Format' ); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# Manually inflate nulls, since we are not doing automatic assignment |
31
|
4
|
100
|
|
|
|
10020
|
$log->inflate_nulls if $log->isa('Log::Any::Proxy::Null'); |
32
|
|
|
|
|
|
|
|
33
|
4
|
50
|
|
|
|
21
|
if ($lite) { |
|
|
0
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# Using Mojolicious::Lite |
35
|
|
|
|
|
|
|
|
36
|
4
|
100
|
|
|
|
20
|
return if $caller->app->log->isa('Log::Any::Proxy'); |
37
|
2
|
|
|
|
|
136
|
$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__ |