Adam Thomason > Log-Syslog-DangaSocket-1.06 > Log::Syslog::DangaSocket

Download:
Log-Syslog-DangaSocket-1.06.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 1.06   Source  

NAME ^

Log::Syslog::DangaSocket - Danga::Socket wrapper around a syslog sending socket (TCP, UDP, or UNIX).

SYNOPSIS ^

    my $logger = Log::Syslog::DangaSocket->new(
        $proto,         # 'udp', 'tcp', or 'unix'
        $dest_host,     # destination hostname or filename
        $dest_port,     # destination port (ignored for unix socket)
        $sender_host,   # sender hostname (informational only)
        $sender_name,   # sender application name (informational only)
        $facility,      # syslog facility number
        $severity,      # syslog severity number
        $reconnect      # whether to reconnect on error
    );

    Danga::Socket->AddTimer(5, sub { $logger->send("5 seconds elapsed") });

    Danga::Socket->EventLoop;

DESCRIPTION ^

This module constructs and asynchronously sends syslog packets to a syslogd listening on a TCP or UDP port, or a UNIX socket. Calls to $logger->send() are guaranteed to never block; though naturally, this only works in the context of a running Danga::Socket event loop.

UDP support is present primarily for completeness; an implementation like Log::Syslog::Fast will provide non-blocking behavior with less overhead. Only in the unlikely case of the local socket buffer being full will this module benefit you by buffering the failed write and retrying it when possible, instead of silently dropping the message. But you should really be using TCP or a domain socket if you care about reliability.

Trailing newlines are added automatically to log messages.

ERROR HANDLING

If a fatal occur occurs during sending (e.g. the connection is remotely closed or reset), Log::Syslog::DangaSocket will attempt to automatically reconnect if $reconnect is true. Any pending writes from the closed connection will be retried in the new one.

SEE ALSO ^

Danga::Socket

Log::Syslog::Constants

Log::Syslog::Fast

AUTHOR ^

Adam Thomason, <athomason@sixapart.com>

COPYRIGHT AND LICENSE ^

Copyright (C) 2009 by Six Apart, <cpan@sixapart.com>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.

syntax highlighting: