| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# ABSTRACT: a place to store captured Dancer2 logs |
|
2
|
|
|
|
|
|
|
$Dancer2::Logger::Capture::Trap::VERSION = '0.400000'; |
|
3
|
|
|
|
|
|
|
use Moo; |
|
4
|
10
|
|
|
10
|
|
59
|
use Dancer2::Core::Types; |
|
|
10
|
|
|
|
|
28
|
|
|
|
10
|
|
|
|
|
56
|
|
|
5
|
10
|
|
|
10
|
|
3403
|
|
|
|
10
|
|
|
|
|
66
|
|
|
|
10
|
|
|
|
|
130
|
|
|
6
|
|
|
|
|
|
|
has storage => ( |
|
7
|
|
|
|
|
|
|
is => 'rw', |
|
8
|
|
|
|
|
|
|
isa => ArrayRef, |
|
9
|
|
|
|
|
|
|
default => sub { [] }, |
|
10
|
|
|
|
|
|
|
); |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my ( $self, $level, $message, $fmt_string ) = @_; |
|
13
|
|
|
|
|
|
|
push @{ $self->storage }, { |
|
14
|
15
|
|
|
15
|
1
|
53
|
level => $level, |
|
15
|
15
|
|
|
|
|
26
|
message => $message, |
|
|
15
|
|
|
|
|
298
|
|
|
16
|
|
|
|
|
|
|
formatted => $fmt_string, |
|
17
|
|
|
|
|
|
|
}; |
|
18
|
|
|
|
|
|
|
} |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $self = shift; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $logs = $self->storage; |
|
23
|
13
|
|
|
13
|
1
|
11990
|
$self->storage( [] ); |
|
24
|
|
|
|
|
|
|
return $logs; |
|
25
|
13
|
|
|
|
|
241
|
} |
|
26
|
13
|
|
|
|
|
395
|
|
|
27
|
13
|
|
|
|
|
390
|
1; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=pod |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=encoding UTF-8 |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 NAME |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Dancer2::Logger::Capture::Trap - a place to store captured Dancer2 logs |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 VERSION |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
version 0.400000 |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
my $trap = Dancer2::Logger::Capture::Trap->new; |
|
45
|
|
|
|
|
|
|
$trap->store( $level, $message ); |
|
46
|
|
|
|
|
|
|
my $logs = $trap->read; |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
This is a place to store and retrieve capture Dancer2 logs used by |
|
51
|
|
|
|
|
|
|
L<Dancer2::Logger::Capture>. |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 Methods |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head3 new |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head3 store |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
$trap->store($level, $message); |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Stores a log $message and its $level. |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head3 read |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
my $logs = $trap->read; |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Returns the logs stored as an array ref and clears the storage. |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
For example... |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
[{ level => "warning", message => "Danger! Warning! Dancer2!" }, |
|
72
|
|
|
|
|
|
|
{ level => "error", message => "You fail forever" } |
|
73
|
|
|
|
|
|
|
]; |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
L<Dancer2::Logger::Capture> |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 AUTHOR |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Dancer Core Developers |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This software is copyright (c) 2022 by Alexis Sukrieh. |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
88
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |