A structured logger for Fluentd (Perl)
Perl Perl6
Latest commit 81001ce Jun 2, 2016 @fujiwara fujiwara Checking in changes prior to tagging of version 0.18.
Changelog diff is:

diff --git a/Changes b/Changes
index 182af76..fa200d3 100644
--- a/Changes
+++ b/Changes
@@ -2,6 +2,9 @@ Revision history for Fluent::Logger

 {{$NEXT}}

+0.18 2016-06-02T05:52:34Z
+  * Support Sub-second time (for Fluentd 0.14 or later)
+
 0.17 2016-05-26T07:57:21Z
   * Fix error handling (Fluent::Logger::UDP)

README.md

Build Status

NAME

Fluent::Logger - A structured event logger for Fluent

SYNOPSIS

use Fluent::Logger;

my $logger = Fluent::Logger->new(
    host => '127.0.0.1',
    port => 24224,
);
$logger->post("myapp.access", { "agent" => "foo" });
# output: myapp.access {"agent":"foo"}

my $logger = Fluent::Logger->new(
    tag_prefix => 'myapp',
    host       => '127.0.0.1',
    port       => 24224,
);
$logger->post("access", { "agent" => "foo" });
# output: myapp.access {"agent":"foo"}

DESCRIPTION

Fluent::Logger is a structured event logger for Fluent.

METHODS

  • new(%args)

    create new logger instance.

    %args:

    tag_prefix     => 'Str':  optional
    host           => 'Str':  default is '127.0.0.1'
    port           => 'Int':  default is 24224
    timeout        => 'Num':  default is 3.0
    socket         => 'Str':  default undef (e.g. "/var/run/fluent/fluent.sock")
    prefer_integer => 'Bool': default 1 (set to Data::MessagePack->prefer_integer)
    event_time     => 'Bool': default 0 (timestamp includes nanoseconds, supported by fluentd >= 0.14.0)
    
  • post($tag:Str, $msg:HashRef)

    Send message to fluent server with tag.

    Return bytes length of written messages.

    If event_time is set to true, log's timestamp includes nanoseconds.

  • post_with_time($tag:Str, $msg:HashRef, $time:Int|Float)

    Send message to fluent server with tag and time.

    If event_time is set to true, $time argument accepts Float value (such as Time::HiRes::time()).

  • close()

    close connection.

    If the logger has pending data, flushing it to server on close.

  • errstr

    return error message.

    $logger->post( info => { "msg": "test" } )
        or die $logger->errstr;
    

AUTHOR

HIROSE Masaaki

Shinichiro Sei

FUJIWARA Shunichiro

THANKS TO

Kazuki Ohta

FURUHASHI Sadayuki

lestrrat

REPOSITORY

https://github.com/fluent/fluent-logger-perl

git clone git://github.com/fluent/fluent-logger-perl.git

patches and collaborators are welcome.

SEE ALSO

http://fluent.github.com/

COPYRIGHT & LICENSE

Copyright FUJIWARA Shunichiro

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.