Permalink
Browse files

Merge pull request #2 from lestrrat/master

Shouldn't need to set prefer_integer for every post() operation
  • Loading branch information...
2 parents 76302fb + 94d507f commit b02c49615e2a5373dad63d7c6e4c9a26c8d1ed91 @fujiwara fujiwara committed Jan 31, 2012
Showing with 13 additions and 1 deletion.
  1. +4 −1 lib/Fluent/Logger.pm
  2. +9 −0 t/05_prefer_integer.t
View
@@ -82,6 +82,10 @@ has prefer_integer => (
is => "rw",
isa => "Bool",
default => 1,
+ trigger => sub {
+ my ($self, $new_value) = @_;
+ $self->packer->prefer_integer( $new_value );
+ }
);
has packer => (
@@ -215,7 +219,6 @@ sub _post {
$tag = join('.', $self->tag_prefix, $tag) if $self->tag_prefix;
- $self->packer->prefer_integer( $self->prefer_integer );
my $data = $self->packer->pack([ "$tag", int $time, $msg ]);
$self->_send($data);
View
@@ -13,6 +13,15 @@ my $port = $server->port;
use_ok "Fluent::Logger";
+subtest 'prefer_integer trigger' => sub {
+ my $logger = Fluent::Logger->new(
+ prefer_integer => 0
+ );
+
+ is $logger->packer->get_prefer_integer, 0, "prefer_integer = 0";
+ $logger->prefer_integer( 1 );
+ is $logger->packer->get_prefer_integer, 1, "prefer_integer = 1";
+};
subtest as_int => sub {
my $logger = Fluent::Logger->new(

0 comments on commit b02c496

Please sign in to comment.