[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:57:43 UTC 2013
The following commit has been merged in the master branch:
commit 529253d81845685cb3962f5e77bab5f7b75bf027
Author: Tomas Doran <bobtfish at bobtfish.net>
Date: Mon Sep 3 22:18:03 2012 +0100
More tests, and bug fixes
diff --git a/lib/Message/Passing/Filter/ToLogstash.pm b/lib/Message/Passing/Filter/ToLogstash.pm
index 955a003..15ddac2 100644
--- a/lib/Message/Passing/Filter/ToLogstash.pm
+++ b/lib/Message/Passing/Filter/ToLogstash.pm
@@ -23,7 +23,7 @@ has add_tags => (
);
my %map = (
- '__CLASS__' => [ 'perl:Class', 'type' ],
+ '__CLASS__' => [ 'perl:Class:', 'type' ],
hostname => 'source_host',
message => 'message',
filename => 'source_path',
@@ -44,15 +44,15 @@ sub filter {
}
$message = { '@fields' => { %$message } };
if (exists($message->{'@fields'}{epochtime})) {
- $message->{'@timestamp'} = DateTime->from_epoch(epoch => delete($message->{'@fields'}{epochtime}))
+ $message->{'@timestamp'} = DateTime->from_epoch(epoch => delete($message->{'@fields'}{epochtime})) . ''
}
foreach my $k (keys %map) {
my $v = $map{$k};
$v = [ '', $v ] if !ref $v;
my ($prefix, $field) = @$v;
$field = '@' . $field;
- if (exists($message->{'@fields'}{$field}) && !exists($message->{$field})) {
- $message->{$field} = $prefix . delete $message->{'@fields'}{$field};
+ if (exists($message->{'@fields'}{$k}) && !exists($message->{$field})) {
+ $message->{$field} = $prefix . delete $message->{'@fields'}{$k};
}
}
$message->{'@tags'} ||= $self->default_tags;
diff --git a/t/filter_tologstash.t b/t/filter_tologstash.t
index 1fea4dc..717aa2b 100644
--- a/t/filter_tologstash.t
+++ b/t/filter_tologstash.t
@@ -1,12 +1,47 @@
use strict;
use warnings;
use Test::More;
+use Data::Dumper;
-use_ok 'Message::Passing::Filter::ToLogStash';
-use_ok 'Message::Passing::Output::Test';
+use Message::Passing::Filter::ToLogStash;
+use Message::Passing::Output::Test;
+use Sys::Hostname;
+
+no warnings 'redefine';
+sub AnyEvent::now { 1346706534 }
+use warnings 'redefine';
my @data = (
- [ 'Simple empty hash', {}, { '@fields' => {}, '@tags' => [] } ],
+ [
+ 'Simple empty hash',
+ {},
+ { '@fields' => {}, '@tags' => [] }
+ ],
+ [
+ 'MX::Storage',
+ { '__CLASS__' => 'Moo', foo => 'bar' },
+ { '@fields' => { foo => 'bar' }, '@tags' => [], '@type' => 'perl:Class:Moo' },
+ ],
+ [
+ 'timestamp from epoch',
+ { epochtime => 1346706534 },
+ { '@fields' => {}, '@tags' => [], '@timestamp' => '2012-09-03T21:08:54' },
+ ],
+ [
+ 'raw message',
+ 'foo',
+ { '@fields' => {}, '@tags' => [], '@message' => 'foo', '@source_host' => hostname(), '@timestamp' => '2012-09-03T21:08:54', '@type' => 'generic_line' },
+ ],
+ [
+ 'filename',
+ { filename => '/foo/bar', 'message' => 'foo' },
+ { '@fields' => {}, '@tags' => [], '@message' => 'foo', '@source_path' => '/foo/bar' },
+ ],
+ [
+ 'date field, no epoch',
+ { date => '2012-09-03T21:08:54', message => 'foo',},
+ { '@fields' => {}, '@tags' => [], '@message' => 'foo', '@timestamp' => '2012-09-03T21:08:54' },
+ ],
);
foreach my $datum (@data) {
@@ -17,7 +52,8 @@ foreach my $datum (@data) {
);
$in->consume($input);
my ($output) = $out->messages;
- is_deeply $output, $exp, $name;
+ is_deeply $output, $exp, $name
+ or diag "Got " . Dumper($output) . " expected " . Dumper($exp);
}
done_testing;
--
libmessage-passing-perl Debian packaging
More information about the Pkg-perl-cvs-commits
mailing list