| 1 | package Dancer2::Logger::Capture::Trap; | ||
| 2 | # ABSTRACT: a place to store captured Dancer2 logs | ||
| 3 | 15 | $Dancer2::Logger::Capture::Trap::VERSION = '2.3.0'; | |
| 4 | 15 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 15 | ▶ | use Dancer2::Core::Types; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | has storage => ( | ||
| 8 | is => 'rw', | ||
| 9 | isa => ArrayRef, | ||
| 10 | 25 | ▶ | default => sub { [] }, |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 11 | 15 | ); | |
| 12 | |||
| 13 | 66 | ▶ | sub store { |
|
Subroutine
store: called CC=1 SCAR=0.0
Pod
documented
| |||
| 14 | 66 | my ( $self, $level, $message, $fmt_string ) = @_; | |
| 15 | 66 | push @{ $self->storage }, { | |
| 16 | level => $level, | ||
| 17 | message => $message, | ||
| 18 | formatted => $fmt_string, | ||
| 19 | }; | ||
| 20 | } | ||
| 21 | |||
| 22 | 28 | ▶ | sub read { |
|
Subroutine
read: called CC=1 SCAR=0.0
Pod
documented
| |||
| 23 | 28 | my $self = shift; | |
| 24 | |||
| 25 | 28 | my $logs = $self->storage; | |
| 26 | 28 | $self->storage( [] ); | |
| 27 | 28 | return $logs; | |
| 28 | } | ||
| 29 | |||
| 30 | 15 | 1; | |
| 31 | |||
| 32 | __END__ | ||