summaryrefslogtreecommitdiff
path: root/t/testdisp.pl
blob: a1911db39b96817a70b54e5a6e21c7688429ae31 (plain)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
##################################################
# String dispatcher for testing
##################################################

package Log::Dispatch::String;

use Log::Dispatch::Output;
use base qw( Log::Dispatch::Output );
use fields qw( stderr );

sub new
{
    my $proto = shift;
    my $class = ref $proto || $proto;
    my %params = @_;

    my $self = bless {}, $class;

    $self->_basic_init(%params);
    $self->{stderr} = exists $params{stderr} ? $params{stderr} : 1;
    $self->{buffer} = "";

    return $self;
}

sub log_message
{   
    my $self = shift;
    my %params = @_;

    $self->{buffer} .= $params{message};
}

sub buffer
{   
    my($self, $new) = @_;

    if(defined $new) {
        $self->{buffer} = $new;
    }

    return $self->{buffer};
}

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

    $self->{buffer} = "";
}

1;