NAME

Log::Radis - Radis is a graylog logging radio through a redis database

VERSION

version 0.001

SYNOPSIS

# default values shown below
my $radis = Log::Radis->new(
    server => 'localhost:6379',
    reconnect => 5,
    every => 1,
    queue => 'graylog-radis:queue',
);

$radis->log(error => "This is a non-urgent error");

DESCRIPTION

Radis (from Radio and Redis) is a concept of caching GELF messages in a Redis DB. Redis provides a reliable queue via the (B)RPOPLPUSH command. See http://redis.io/commands/rpoplpush for more information about that mechanism.

The implementation of a Radis client is quite simple: just push a GELF message with the LPUSH command onto the queue. A collector fetches the messages from the queue and inserts them into a Graylog2 server, for example.

ATTRIBUTES

server

The Redis DB server we should connect to.

See "server" in Redis for allowed values. Defaults to localhost:6379.

reconnect

Re-try connecting to the Redis DB up to reconnect seconds. 0 disables auto-reconnect.

See "reconnect" in Redis for more information.

every

Re-try connection to the Redis DB every every milliseconds.

See "every" in Redis for more information.

queue

The name of the list, which gelf streams are pushed to. Defaults to graylog-radis:queue.

redis

Set or get the Redis instance. Defaults to an instance of Redis. Any blessed object which implements the method lpush is allowed.

For your own Redis implementation use this attribute in the constructor. That should work:

my $redis = AnyEvent::Redis->new(...);
my $radis = Log::Radis->new(redis => $redis);
my $cv = $radis->log(...);
$cv->recv;

METHODS

log

$radis->log($level, $message, %additional_gelf_params);
$radis->log(alert => "This is an alert!");
$radis->log(notice => "Look at this.", additional_param => $additional_value);

Additional GELF params must be prefixed with an underscore - but this method does that for you.

Overrides are only allowed for host/hostname and timestamp/time params. They defaults to the system hostname and the current timestamp from "time" in Time::HiRes.

push

$radis->push({ ... });

Raw-push a gelf message onto queue. If the argument is not a HashRef, it will be encoded to a JSON string.

The input is not validated, so be careful what you push onto the queue.

LOG LEVELS

These levels are known and supposed to be compatible to various other logging engines.

Identifier | Numeric level
-----------+--------------
fatal      | 1
emerg      | 1
emergency  | 1
-----------+---
alert      | 2
-----------+---
crit       | 3
critical   | 3
-----------+---
error      | 4
err        | 4
-----------+---
warn       | 5
warning    | 5
-----------+---
note       | 6
notice     | 6
-----------+---
info       | 7
-----------+---
debug      | 8
-----------+---
trace      | 9
core       | 9

BUGS

Please report any bugs or feature requests on the bugtracker website https://github.com/zurborg/liblog-radis-perl/issues

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

AUTHOR

David Zurborg <zurborg@cpan.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2016 by David Zurborg.

This is free software, licensed under:

The ISC License