1N/A# tom christiansen <tchrist@convex.com> 1N/A# modified to use sockets by Larry Wall <lwall@jpl-devvax.jpl.nasa.gov> 1N/A# NOTE: openlog now takes three arguments, just like openlog(3) 1N/A# call syslog() with a string priority and a list of printf() args 1N/A# then (put these all in a script to test function) 1N/A# do openlog($program,'cons,pid','user'); 1N/A# do syslog('info','this is another test'); 1N/A# do syslog('mail|warning','this is a better test: %d', time); 1N/A# do syslog('debug','this is the last test'); 1N/A# do openlog("$program $$",'ndelay','user'); 1N/A# do syslog('notice','fooprogram: this is really done'); 1N/A# do syslog('info','problem was %m'); # %m == $! in syslog(3) 1N/A$
host =
'localhost' unless $
host;
# set $syslog'host to change 1N/A warnings::
warn(
"You should 'use Sys::Syslog' instead; continuing");
1N/A eval 'use Socket; 1' ||
1N/A eval {
require "socket.ph" } ||
1N/A die "syslog: too many levels given: $_\n" if defined($
numpri);
1N/A die "syslog: too many facilities given: $_\n" if defined($
numfac);
1N/A die "syslog: level must be given\n" unless defined($
numpri);
1N/A if (!
defined($
numfac)) {
# Facility not specified in this call. 1N/A unless (
send(
SYSLOG,
"<$sum>$whoami: $message",
0)) {
1N/A print CONS "<$facility.$priority>$whoami: $message\r";
1N/A exit if defined $
pid;
# if fork failed, we're parent 1N/A die "Can't lookup $myname\n" unless $
name;
1N/A die "Can't lookup $host\n" unless $
name;