NAME

Log::Syslog::Fast - Perl extension for very quickly sending syslog messages over TCP or UDP.

SYNOPSIS

use Log::Syslog::Fast;
my $logger = Log::Syslog::Fast->new(LOG_UDP, "127.0.0.1", 514, 16, 6, "mymachine", "logger");
$logger->send("log message", time);

DESCRIPTION

This module sends syslog messages over a network socket. It works like Sys::Syslog in setlogsock's 'udp' or 'tcp' modes, but without the significant CPU overhead of that module when used for high-volume logging. Use of this specialized module is only necessary if 1) you must use network syslog as a messaging transport but 2) need to minimize the time spent in the logger.

This module supercedes the less general Log::Syslog::UDP.

METHODS

Log::Syslog::Fast->new($proto, $hostname, $port, $facility, $severity, $sender, $name);

Create a new Log::Syslog::Fast object with the following parameters:

$proto

The transport protocol, either LOG_TCP or LOG_UDP.

If LOG_TCP is used, calls to $logger->send() will block until remote receipt of the message is confirmed. If LOG_UDP is used, the call will never block and may fail if insufficient buffer space exists in the network stack.

$hostname

The destination hostname where a syslogd is running.

$port

The destination port where a syslogd is listening. Usually 514.

$facility

The syslog facility constant, eg 16 for 'local0'. See RFC3164 section 4.1.1 (or <sys/syslog.h>) for appropriate constant values.

$severity

The syslog severity constant, eg 6 for 'info'. See RFC3164 section 4.1.1 (or <sys/syslog.h>) for appropriate constant values.

$sender

The originating hostname. Sys::Hostname::hostname is typically a reasonable source for this.

$name

The program name or tag to use for the message.

$logger->send($logmsg, [$time])

Send a syslog message through the configured logger. If $time is not provided, CORE::time() will be called for you. That doubles the syscalls per message, so try to pass it if you're already calling time() yourself.

$logger->set_receiver($hostname, $port)

Change the destination host and port. This will force a reconnection in LOG_TCP mode.

$logger->set_priority($facility, $severity)

Change the syslog facility and severity.

$logger->set_sender($sender)

Change what is sent as the hostname of the sender.

$logger->set_name($name)

Change what is sent as the name of the sending program.

$logger->set_pid($name)

Change what is sent as the process id of the sending program.

EXPORT

You may optionally import constants for severity and facility levels.

use Log::Syslog::Fast qw(:protos); # LOG_TCP and LOG_UDP
use Log::Syslog::Fast qw(:severities); # LOG_CRIT, LOG_NOTICE, LOG_DEBUG, etc
use Log::Syslog::Fast qw(:facilities); # LOG_CRON, LOG_LOCAL3, etc
use Log::Syslog::Fast qw(:all); # all of the above

SEE ALSO

Sys::Syslog

AUTHOR

Adam Thomason, <athomason@sixapart.com>

COPYRIGHT AND LICENSE

Copyright (C) 2008 by Six Apart, Ltd.

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.5 or, at your option, any later version of Perl 5 you may have available.