| 1 | package Log::Abstraction::Backend::Array; | ||||||||||
| 2 | |||||||||||
| 3 | # The array backend: push the history entry onto an array | ||||||||||
| 4 | 42 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 42 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 42 | ▶ | use parent 'Log::Abstraction::Backend'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 42 | our $VERSION = '0.40'; | |||||||||
| 10 | |||||||||||
| 11 | =head1 NAME | ||||||||||
| 12 | |||||||||||
| 13 | Log::Abstraction::Backend::Array - push messages onto an array | ||||||||||
| 14 | |||||||||||
| 15 | =head1 VERSION | ||||||||||
| 16 | |||||||||||
| 17 | 0.40 | ||||||||||
| 18 | |||||||||||
| 19 | =head1 DESCRIPTION | ||||||||||
| 20 | |||||||||||
| 21 | Built for C<logger =E<gt> \@array>, a top-level C<array>, or the C<array> | ||||||||||
| 22 | key of a C<logger> hash. Pushes C<{ level, message }> hash references, with | ||||||||||
| 23 | C<fields> when the message has structured fields. With a C<format>, the | ||||||||||
| 24 | C<message> is the formatted line. | ||||||||||
| 25 | |||||||||||
| 26 | For use by L<Log::Abstraction> only; see L<Log::Abstraction::Backend>. | ||||||||||
| 27 | |||||||||||
| 28 | =head1 METHODS | ||||||||||
| 29 | |||||||||||
| 30 | =head2 emit | ||||||||||
| 31 | |||||||||||
| 32 | $backend->emit($logger, $event); | ||||||||||
| 33 | |||||||||||
| 34 | =cut | ||||||||||
| 35 | |||||||||||
| 36 | 10812 | ▶ | sub emit { | ||||||||
|
Subroutine
emit: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 37 | 10812 | my ($self, $logger, $event) = @_; | |||||||||
| 38 | |||||||||||
| 39 | 10812 | push @{$self->{'array'}}, { | |||||||||
| 40 | 10812 | ▶ | @{$event->{'entry'}}, | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | 10812 | (defined($self->{'format'}) ? (message => $event->{'render'}->($self->{'format'})) : ()), | |||||||||
| 42 | }; | ||||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | =head1 AUTHOR | ||||||||||
| 46 | |||||||||||
| 47 | Nigel Horne C<njh@nigelhorne.com> | ||||||||||
| 48 | |||||||||||
| 49 | =head1 SEE ALSO | ||||||||||
| 50 | |||||||||||
| 51 | L<Log::Abstraction>, L<Log::Abstraction::Backend> | ||||||||||
| 52 | |||||||||||
| 53 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 54 | |||||||||||
| 55 | Copyright (C) 2025-2026 Nigel Horne | ||||||||||
| 56 | |||||||||||
| 57 | Usage is subject to the GPL2 licence terms. | ||||||||||
| 58 | If you use it, | ||||||||||
| 59 | please let me know. | ||||||||||
| 60 | |||||||||||
| 61 | =cut | ||||||||||
| 62 | |||||||||||
| 63 | 42 | 1; | |||||||||