[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:52 UTC 2013


The following commit has been merged in the master branch:
commit 125c7de94246b8179e7d308d88839156e679cf7e
Author: Tomas Doran <bobtfish at bobtfish.net>
Date:   Sun Apr 22 15:05:22 2012 +0100

    File output

diff --git a/lib/Log/Stash/Output/File.pm b/lib/Log/Stash/Output/File.pm
new file mode 100644
index 0000000..aa6a7a4
--- /dev/null
+++ b/lib/Log/Stash/Output/File.pm
@@ -0,0 +1,88 @@
+package Log::Stash::Output::File;
+use Moose;
+use namespace::autoclean;
+
+with 'Log::Stash::Role::Output';
+
+has filename => (
+    isa => 'Str',
+    is => 'ro',
+    predicate => '_has_filename',
+);
+
+has fh => (
+    is => 'ro',
+    lazy => 1,
+    builder => '_build_fh',
+);
+
+has append => (
+    is => 'ro',
+    isa => 'Bool',
+    default => 1,
+);
+
+sub _build_fh {
+    my $self = shift;
+    confess("Need a filename to output to") unless $self->_has_filename;
+    my $mode = $self->append ? '>>' : '>';
+    open(my $fh, $mode, $self->filename) or confess("Could not open ".
+        $self->filename . " for writing: $!");
+    $fh;
+}
+
+sub BUILD {
+    my $self = shift;
+    $self->fh;
+}
+
+sub consume {
+    my $self = shift;
+    my $saved = select($self->fh);
+    local $|=1;
+    print $self->encode(shift()) . "\n";
+    select($saved);
+    return 1;
+}
+
+__PACKAGE__->meta->make_immutable;
+1;
+
+=head1 NAME
+
+Log::Stash::Output::File - File output
+
+=head1 SYNOPSIS
+
+    logstash --input STDIN --output File
+    {"foo": "bar"}
+    {"foo":"bar"}
+
+=head1 DESCRIPTION
+
+Output messages to File
+
+=head1 METHODS
+
+=head2 consume
+
+Consumes a message by JSON encoding it and printing it, followed by \n
+
+=head1 SEE ALSO
+
+L<Log::Stash>
+
+=head1 SPONSORSHIP
+
+This module exists due to the wonderful people at Suretec Systems Ltd.
+<http://www.suretecsystems.com/> who sponsored it's development for its
+VoIP division called SureVoIP <http://www.surevoip.co.uk/> for use with
+the SureVoIP API - 
+<http://www.surevoip.co.uk/support/wiki/api_documentation>
+
+=head1 AUTHOR, COPYRIGHT AND LICENSE
+
+See L<Log::Stash>.
+
+=cut
+
diff --git a/t/00_compile.t b/t/00_compile.t
index 98e55cb..a50adae 100644
--- a/t/00_compile.t
+++ b/t/00_compile.t
@@ -6,9 +6,11 @@ use Test::More;
 use_ok('Log::Stash');
 use_ok('Log::Stash::Output::STDOUT');
 use_ok('Log::Stash::Input::STDIN');
+use_ok('Log::Stash::Input::FileTail');
 use_ok('Log::Stash::Output::Null');
 use_ok('Log::Stash::Output::Callback');
 use_ok('Log::Stash::Output::Test');
+use_ok('Log::Stash::Output::File');
 use_ok('Log::Stash::Filter::Null');
 use_ok('Log::Stash::Filter::All');
 use_ok('Log::Stash::Filter::Delay');

-- 
libmessage-passing-perl Debian packaging



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