| 1 | package DBIx::Class::UnicornLogger::FromProfile; | ||||||||||||||||||||
| 2 | 1 | $DBIx::Class::UnicornLogger::FromProfile::VERSION = '0.001004'; | |||||||||||||||||||
| 3 | # ABSTRACT: Define your UnicornLogger with a single string! | ||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 1 | ▶ | use Moo; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 1 | extends 'DBIx::Class::UnicornLogger'; | |||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 2 | ▶ | sub get_profile { | ||||||||||||||||||
|
Subroutine
get_profile: called CC=3 SCAR=11.6
Pod
undocumented
| |||||||||||||||||||||
| 10 | 2 | my ($self, $profile_name) = @_; | |||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 2 | my $ret = {}; | |||||||||||||||||||
| 13 | 2 | ▶ | if ($profile_name) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 14 | 2 | ▶ | if (my $profile = $self->profiles->{$profile_name}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 15 | 2 | $ret = $profile | |||||||||||||||||||
| 16 | } else { | ||||||||||||||||||||
| 17 | 0 | warn "no such profile: '$_[1]', using empty profile instead"; | |||||||||||||||||||
| 18 | } | ||||||||||||||||||||
| 19 | } | ||||||||||||||||||||
| 20 | 2 | return $ret | |||||||||||||||||||
| 21 | } | ||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 2 | ▶ | sub profiles { | ||||||||||||||||||
|
Subroutine
profiles: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||
| 24 | my @good_executing = ( | ||||||||||||||||||||
| 25 | executing => | ||||||||||||||||||||
| 26 | 2 | ▶ | eval { require Term::ANSIColor } ? do { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 27 | 2 | my $c = \&Term::ANSIColor::color; | |||||||||||||||||||
| 28 | 2 | $c->('blink white on_black') . 'EXECUTING...' . $c->('reset'); | |||||||||||||||||||
| 29 | } : 'EXECUTING...' | ||||||||||||||||||||
| 30 | ); | ||||||||||||||||||||
| 31 | return { | ||||||||||||||||||||
| 32 | 2 | 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 | 2 | ▶ | sub BUILDARGS { | ||||||||||||||||||
|
Subroutine
BUILDARGS: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||||||||
| 61 | 2 | my ($self, @rest) = @_; | |||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | my %args = ( | ||||||||||||||||||||
| 64 | @rest == 1 | ||||||||||||||||||||
| 65 | 0 | ▶ | ? %{$rest[0]} | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 66 | : @rest | ||||||||||||||||||||
| 67 | ); | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | 2 | my $profile = delete $args{unicorn_profile}; | |||||||||||||||||||
| 70 | %args = ( | ||||||||||||||||||||
| 71 | 2 | ▶ | %{$self->get_profile($ENV{DBIC_UNICORN_PROFILE} || $profile)}, | ||||||||||||||||||
|
Condition66%2/3
$ENV{'DBIC_UNICORN_PROFILE'} || $profile
MC/DC0%0/2
$ENV{'DBIC_UNICORN_PROFILE'} || $profile
$ENV{'DBIC_UNICORN_PROFILE'}
$profile
Truth table66%2/3
A || B
A= $ENV{'DBIC_UNICORN_PROFILE'}B= $profile
| |||||||||||||||||||||
| 72 | %args, | ||||||||||||||||||||
| 73 | ); | ||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | 2 | return $self->next::method(\%args) | |||||||||||||||||||
| 76 | } | ||||||||||||||||||||
| 77 | |||||||||||||||||||||
| 78 | 1 | 1; | |||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | __END__ | ||||||||||||||||||||