line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBIx::Class::UnicornLogger::FromProfile; |
2
|
|
|
|
|
|
|
$DBIx::Class::UnicornLogger::FromProfile::VERSION = '0.001004'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Define your UnicornLogger with a single string! |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
16788
|
use Moo; |
|
1
|
|
|
|
|
12312
|
|
|
1
|
|
|
|
|
5
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
extends 'DBIx::Class::UnicornLogger'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub get_profile { |
10
|
2
|
|
|
2
|
0
|
5
|
my ($self, $profile_name) = @_; |
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
|
|
3
|
my $ret = {}; |
13
|
2
|
50
|
|
|
|
6
|
if ($profile_name) { |
14
|
2
|
50
|
|
|
|
6
|
if (my $profile = $self->profiles->{$profile_name}) { |
15
|
2
|
|
|
|
|
5
|
$ret = $profile |
16
|
|
|
|
|
|
|
} else { |
17
|
0
|
|
|
|
|
0
|
warn "no such profile: '$_[1]', using empty profile instead"; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
} |
20
|
2
|
|
|
|
|
24
|
return $ret |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub profiles { |
24
|
|
|
|
|
|
|
my @good_executing = ( |
25
|
|
|
|
|
|
|
executing => |
26
|
2
|
50
|
|
2
|
0
|
4
|
eval { require Term::ANSIColor } ? do { |
|
2
|
|
|
|
|
792
|
|
27
|
2
|
|
|
|
|
7012
|
my $c = \&Term::ANSIColor::color; |
28
|
2
|
|
|
|
|
10
|
$c->('blink white on_black') . 'EXECUTING...' . $c->('reset'); |
29
|
|
|
|
|
|
|
} : 'EXECUTING...' |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
return { |
32
|
2
|
|
|
|
|
171
|
console => { |
33
|
|
|
|
|
|
|
tree => { profile => 'console' }, |
34
|
|
|
|
|
|
|
clear_line => "\r\x1b[J", |
35
|
|
|
|
|
|
|
show_progress => 1, |
36
|
|
|
|
|
|
|
@good_executing, |
37
|
|
|
|
|
|
|
}, |
38
|
|
|
|
|
|
|
console_monochrome => { |
39
|
|
|
|
|
|
|
tree => { profile => 'console_monochrome' }, |
40
|
|
|
|
|
|
|
clear_line => "\r\x1b[J", |
41
|
|
|
|
|
|
|
show_progress => 1, |
42
|
|
|
|
|
|
|
@good_executing, |
43
|
|
|
|
|
|
|
}, |
44
|
|
|
|
|
|
|
plain => { |
45
|
|
|
|
|
|
|
tree => { profile => 'console_monochrome' }, |
46
|
|
|
|
|
|
|
clear_line => "DONE\n", |
47
|
|
|
|
|
|
|
show_progress => 1, |
48
|
|
|
|
|
|
|
executing => 'EXECUTING...', |
49
|
|
|
|
|
|
|
}, |
50
|
|
|
|
|
|
|
demo => { |
51
|
|
|
|
|
|
|
tree => { profile => 'console' }, |
52
|
|
|
|
|
|
|
format => '[%d][%F:%L]%n%m', |
53
|
|
|
|
|
|
|
clear_line => "DONE\n", |
54
|
|
|
|
|
|
|
show_progress => 1, |
55
|
|
|
|
|
|
|
executing => 'EXECUTING...', |
56
|
|
|
|
|
|
|
}, |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub BUILDARGS { |
61
|
2
|
|
|
2
|
0
|
5794
|
my ($self, @rest) = @_; |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
0
|
my %args = ( |
64
|
|
|
|
|
|
|
@rest == 1 |
65
|
2
|
50
|
|
|
|
12
|
? %{$rest[0]} |
66
|
|
|
|
|
|
|
: @rest |
67
|
|
|
|
|
|
|
); |
68
|
|
|
|
|
|
|
|
69
|
2
|
|
|
|
|
5
|
my $profile = delete $args{unicorn_profile}; |
70
|
2
|
|
66
|
|
|
17
|
%args = ( |
71
|
2
|
|
|
|
|
4
|
%{$self->get_profile($ENV{DBIC_UNICORN_PROFILE} || $profile)}, |
72
|
|
|
|
|
|
|
%args, |
73
|
|
|
|
|
|
|
); |
74
|
|
|
|
|
|
|
|
75
|
2
|
|
|
|
|
34
|
return $self->next::method(\%args) |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
__END__ |