File Coverage

blib/lib/Stepford/LoggerWithMoniker.pm
Criterion Covered Total %
statement 15 15 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 20 20 100.0


line stmt bran cond sub pod time code
1             package Stepford::LoggerWithMoniker;
2              
3 43     43   282 use strict;
  43         90  
  43         1164  
4 43     43   213 use warnings;
  43         63  
  43         910  
5 43     43   188 use namespace::autoclean;
  43         86  
  43         223  
6              
7             our $VERSION = '0.006000';
8              
9 43     43   17258 use Stepford::Types qw( Logger Str );
  43         145  
  43         321  
10              
11 43     43   278118 use Moose;
  43         99  
  43         351  
12              
13             my $Levels = [qw( debug info notice warning error )];
14              
15             has _logger => (
16             is => 'ro',
17             isa => Logger,
18             init_arg => 'logger',
19             required => 1,
20             handles => $Levels,
21             );
22              
23             has _moniker => (
24             is => 'ro',
25             isa => Str,
26             init_arg => 'moniker',
27             required => 1,
28             );
29              
30             around $Levels => sub {
31             my $orig = shift;
32             my $self = shift;
33             my $message = shift;
34              
35             $message = '[' . $self->_moniker . '] ' . $message;
36              
37             return $self->$orig( $message, @_ );
38             };
39              
40             __PACKAGE__->meta->make_immutable;
41              
42             1;
43              
44             # ABSTRACT: The logger used by Step classes.
45              
46             __END__
47              
48             =pod
49              
50             =encoding UTF-8
51              
52             =head1 NAME
53              
54             Stepford::LoggerWithMoniker - The logger used by Step classes.
55              
56             =head1 VERSION
57              
58             version 0.006000
59              
60             =head1 DESCRIPTION
61              
62             This class wraps the logger passed in by the Runner. It prefixes the messages
63             with the step name. This class has no user-facing parts.
64              
65             =head1 SUPPORT
66              
67             Bugs may be submitted through L<https://github.com/maxmind/Stepford/issues>.
68              
69             =head1 AUTHOR
70              
71             Dave Rolsky <drolsky@maxmind.com>
72              
73             =head1 COPYRIGHT AND LICENSE
74              
75             This software is copyright (c) 2014 - 2019 by MaxMind, Inc.
76              
77             This is free software; you can redistribute it and/or modify it under
78             the same terms as the Perl 5 programming language system itself.
79              
80             =cut