NAME
Log::Syslog::UDP - Perl extension for very quickly sending syslog messages over UDP.
SYNOPSIS
use Log::Syslog::UDP;
my $logger = Log::Syslog::UDP->new("127.0.0.1", 514, 16, 6, "mymachine", "logger");
$logger->send("log message", time);
DESCRIPTION
This module sends syslog messages over a non-blocking UDP socket. It works like Sys::Syslog in setlogsock('udp') mode, 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 UDP syslog as a messaging transport but 2) need to minimize the time spent in the logger.
METHODS
- Log::Syslog::UDP->new($hostname, $port, $facility, $severity, $sender, $name);
-
Create a new Log::Syslog::UDP object with the following parameters:
- $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 calling time() yourself already.
EXPORT
You may optionally import constants for severity and facility levels.
use Log::Syslog::UDP qw(:severities); # LOG_CRIT, LOG_NOTICE, LOG_DEBUG, etc
use Log::Syslog::UDP qw(:facilities); # LOG_CRON, LOG_LOCAL3, etc
use Log::Syslog::UDP qw(:all); # all of the above
SEE ALSO
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.