diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2014-11-01 01:47:12 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2014-11-01 01:47:12 +0000 |
commit | 94566f012421026c8311552f99175a5989eba063 (patch) | |
tree | 0bfd47111b94a1715d14b8c4ab2d82ad1abc09b1 /t/testdisp.pl | |
download | Log-Log4perl-tarball-94566f012421026c8311552f99175a5989eba063.tar.gz |
Log-Log4perl-1.46HEADLog-Log4perl-1.46master
Diffstat (limited to 't/testdisp.pl')
-rw-r--r-- | t/testdisp.pl | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/t/testdisp.pl b/t/testdisp.pl new file mode 100644 index 0000000..a1911db --- /dev/null +++ b/t/testdisp.pl @@ -0,0 +1,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; |