« blib/lib/auto/share/dist/Cmd-Dwarf/app/lib/Dwarf/Plugin/Cache/Memcached/Fast.pm
↑ Summary
blib/lib/auto/share/dist/Cmd-Dwarf/app/lib/Dwarf/Validator/Upload.pm »
| 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; |