Dancer2::Logger::Fluent - Dancer2 logger engine for Fluent::Logger
version 0.06
use Dancer2::Logger::Fluent;
Implements a structured event logger for Fluent via Fluent::Logger.
When a connection to the fluentd agent can't be established, messages are "queued" internally. These messages will be flushed upon subsequent calls to log(), as soon as a connection is established.
fluentd
log()
Writes the log message to Fluent.
The setting logger should be set to Fluent in order to use this logging engine in a Dancer2 application.
Fluent
Below is a simple sample configuration:
logger: "Fluent" engines: logger: Fluent: tag_prefix: "myapp" host: "127.0.0.1" port: 24224
The full list of allowed options are as follows:
Tag prepended to every message, defaults to the configured appname or, if not defined, to the executable's basename.
Host running the fluentd agent, defaults to '127.0.0.1'.
Port listened by the fluentd agent, defaults to 24224.
Timeout in seconds, defaults to 3.0 as implemented in Fluent::Logger.
Socket file location, defaults to undef as implemented in Fluent::Logger.
Whether integer is preferred as cascaded to Data::MessagePack->prefer_integer. Defaults to 1.
Whether event timestamps (includes nanoseconds as supported by fluentd >= 0.14.0) will be included. Defaults to 0.
Buffer size limit, defaults to 8388608 (8MB) as implemented in Fluent::Logger.
Custom coderef to handle buffer overflow in the event of connection failure, to mitigate loss of data in the event of connection failure.
When truncate_buffer_at_overflow is true and pending buffer size is larger than buffer_limit, pending buffer will still be kept but last message will not be sent and will not be appended to the buffer. Defaults to 0.
Messages to fluentd will be a hash containing the following:
{ env => $environment, timestamp => $current_timestamp, host => $hostname, level => $level, message => $message, pid => $$ }
Arnold Tan Casis <atancasis@cpan.org>
Copyright 2017- Arnold Tan Casis
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See Dancer2 for details about logging in route handlers.
See http://fluent.github.com for details on fluentd itself.
To install Dancer2::Logger::Fluent, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Dancer2::Logger::Fluent
CPAN shell
perl -MCPAN -e shell install Dancer2::Logger::Fluent
For more information on module installation, please visit the detailed CPAN module installation guide.