blib/lib/auto/share/dist/Cmd-Dwarf/app/lib/Dwarf/Plugin/Log/Dispatch.pm untested

filter: Statementstmt 0.0% 0 / 24 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 37 CC 2 SCAR 12.8
CC
2
Cov
0%
init
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 3.6
1 package Dwarf::Plugin::Log::Dispatch;
2 use Dwarf::Pragma;
3 use Dwarf::Util qw/add_method/;
4 use Log::Dispatch;
5  
6 sub init {
7 my ($class, $c, $conf) = @_;
8 $conf ||= {};
9  
10 my $outputs = $conf->{outputs};
11 $outputs ||= [
12 [
13 'Screen',
14 min_level => 'debug',
15 stderr => 1,
16 newline => 1
17 ],
18 ];
19  
20 $c->{'dwarf.log'} = Log::Dispatch->new(outputs => $outputs);
21  
22 add_method($c, log => sub {
23 my $self = shift;
24 return $self->{'dwarf.log'};
25 });
26  
27 add_method($c, debug => sub {
28 my $self = shift;
29 return unless @_;
30 my $message = '[DWARF] ' . join '', @_;
31 $self->{'dwarf.log'}->log(level => 'debug', message => $message);
32 });
33 }
34  
35 1;