File Coverage

blib/lib/Dancer2/Logger/Capture/Trap.pm
Criterion Covered Total %
statement 13 13 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod 2 2 100.0
total 19 19 100.0


line stmt bran cond sub pod time code
1             package Dancer2::Logger::Capture::Trap;
2             # ABSTRACT: a place to store captured Dancer2 logs
3             $Dancer2::Logger::Capture::Trap::VERSION = '2.0.1';
4 12     12   250572 use Moo;
  12         11153  
  12         82  
5 12     12   8680 use Dancer2::Core::Types;
  12         92  
  12         174  
6              
7             has storage => (
8             is => 'rw',
9             isa => ArrayRef,
10             default => sub { [] },
11             );
12              
13             sub store {
14 21     21 1 83 my ( $self, $level, $message, $fmt_string ) = @_;
15 21         48 push @{ $self->storage }, {
  21         814  
16             level => $level,
17             message => $message,
18             formatted => $fmt_string,
19             };
20             }
21              
22             sub read {
23 13     13 1 20726 my $self = shift;
24              
25 13         441 my $logs = $self->storage;
26 13         407 $self->storage( [] );
27 13         580 return $logs;
28             }
29              
30             1;
31              
32             __END__