[SCM] libmessage-passing-perl Debian packaging branch, master, updated. debian/0.111-3-14-g44f6e88

Tomas Doran bobtfish at bobtfish.net
Mon May 6 11:56:40 UTC 2013


The following commit has been merged in the master branch:
commit fd942970444528017ee715385fe7aa7def35c8c7
Author: Tomas Doran <bobtfish at bobtfish.net>
Date:   Sat Mar 3 23:19:13 2012 +0000

    Add ability for filter to actually filter out messages

diff --git a/lib/Log/Stash/Filter/Null.pm b/lib/Log/Stash/Filter/All.pm
similarity index 61%
copy from lib/Log/Stash/Filter/Null.pm
copy to lib/Log/Stash/Filter/All.pm
index 560b132..093d45c 100644
--- a/lib/Log/Stash/Filter/Null.pm
+++ b/lib/Log/Stash/Filter/All.pm
@@ -1,12 +1,11 @@
-package Log::Stash::Filter::Null;
+package Log::Stash::Filter::All;
 use Moose;
 use namespace::autoclean;
 
 with 'Log::Stash::Role::Filter';
 
 sub filter {
-    my ($self, $message) = @_;
-    $message;
+    return;
 }
 
 __PACKAGE__->meta->make_immutable;
diff --git a/lib/Log/Stash/Role/Filter.pm b/lib/Log/Stash/Role/Filter.pm
index 4613c9a..ebaa724 100644
--- a/lib/Log/Stash/Role/Filter.pm
+++ b/lib/Log/Stash/Role/Filter.pm
@@ -7,7 +7,9 @@ with 'Log::Stash::Role::Output';
 
 sub consume {
     my ($self, $message) = @_;
-    $self->output_to->consume($self->filter($message));
+    my $new = $self->filter($message);
+    return unless $new;
+    $self->output_to->consume($new);
 }
 
 requires 'filter';
diff --git a/t/00_compile.t b/t/00_compile.t
index 5bf8c27..1bc4c6e 100644
--- a/t/00_compile.t
+++ b/t/00_compile.t
@@ -8,6 +8,8 @@ use_ok('Log::Stash::Output::STDOUT');
 use_ok('Log::Stash::Input::STDIN');
 use_ok('Log::Stash::Output::Null');
 use_ok('Log::Stash::Output::Test');
+use_ok('Log::Stash::Filter::Null');
+use_ok('Log::Stash::Filter::All');
 
 done_testing;
 
diff --git a/t/filter.t b/t/filter.t
index 31f6388..80a7593 100644
--- a/t/filter.t
+++ b/t/filter.t
@@ -5,6 +5,7 @@ use Try::Tiny;
 
 use Log::Stash::Filter::Null;
 use Log::Stash::Output::Test;
+use Log::Stash::Filter::All;
 
 my $called = 0;
 
@@ -31,5 +32,19 @@ try { $test->clear_messages }
 is $test->messages_count, 0;
 is_deeply [$test->messages], [];
 
+$ob = try {
+    $test = Log::Stash::Output::Test->new(
+            on_consume_cb => sub { $called++ }
+    );
+    Log::Stash::Filter::All->new(output_to => $test)
+}
+catch { fail "Failed to construct $_" };
+ok $test;
+
+try { $ob->consume('message') }
+    catch { fail "Failed to consume message: $_" };
+
+is $test->messages_count, 0;
+
 done_testing;
 

-- 
libmessage-passing-perl Debian packaging



More information about the Pkg-perl-cvs-commits mailing list