File Coverage

blib/lib/App/Embra/Plugin/Zilla/WrapLog.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 16 16 100.0


line stmt bran cond sub pod time code
1 5     5   23 use strict;
  5         8  
  5         173  
2 5     5   24 use warnings;
  5         6  
  5         251  
3              
4             package App::Embra::Plugin::Zilla::WrapLog;
5             $App::Embra::Plugin::Zilla::WrapLog::VERSION = '0.001'; # TRIAL
6             # ABSTRACT: wraps embra logger to suit dzil plugins
7              
8 5     5   22 use Method::Signatures;
  5         7  
  5         27  
9 5     5   3175 use Moo;
  5         27039  
  5         64  
10              
11             with 'App::Embra::Role::Logging';
12              
13             my %_log_level_map = (
14             log => 'info',
15             log_debug => 'debug',
16             log_fatal => 'fatal',
17             );
18              
19             has '_wrap_logger' => (
20             is => 'lazy',
21             handles => \%_log_level_map,
22             default => method { $self->logger },
23             );
24              
25             has 'proxy_prefix' => (
26             is => 'ro',
27             required => 1,
28             );
29              
30             around 'log_prefix' => func( $orig, $self ) {
31             $self->proxy_prefix;
32             };
33              
34             while( my ($w, $r) = each %_log_level_map ) {
35             around $w => func( $orig, $self, $log_msg ) {
36             $self->logger->$r( $self->log_prefix . $log_msg );
37             };
38             }
39              
40             1;
41              
42             __END__
43              
44             =pod
45              
46             =encoding UTF-8
47              
48             =head1 NAME
49              
50             App::Embra::Plugin::Zilla::WrapLog - wraps embra logger to suit dzil plugins
51              
52             =head1 VERSION
53              
54             version 0.001
55              
56             =head1 AUTHOR
57              
58             Daniel Holz <dgholz@gmail.com>
59              
60             =head1 COPYRIGHT AND LICENSE
61              
62             This software is copyright (c) 2015 by Daniel Holz.
63              
64             This is free software; you can redistribute it and/or modify it under
65             the same terms as the Perl 5 programming language system itself.
66              
67             =cut