File: Memory.pm

package info (click to toggle)
liblog-any-adapter-perl 0.11-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 176 kB
  • ctags: 30
  • sloc: perl: 490; makefile: 2
file content (37 lines) | stat: -rw-r--r-- 795 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package Log::Any::Adapter::Test::Memory;
{
  $Log::Any::Adapter::Test::Memory::VERSION = '0.11';
}
use Log::Any::Adapter::Util qw(make_method);
use strict;
use warnings;
use base qw(Log::Any::Adapter::Base);

sub init {
    my ($self) = @_;

    $self->{msgs} = [];
}

foreach my $method ( Log::Any->logging_methods() ) {
    make_method(
        $method,
        sub {
            my ( $self, $text ) = @_;
            push(
                @{ $self->{msgs} },
                {
                    level    => $method,
                    category => $self->{category},
                    text     => $text
                }
            );
        }
    );
}

foreach my $method ( Log::Any->detection_methods() ) {
    make_method( $method, sub { my ( $self, $msg ) = @_; return 1 } );
}

1;