#
#
# $Log: syslog.pl,v $
#
# tom christiansen <tchrist@convex.com>
# modified to use sockets by Larry Wall <lwall@jpl-devvax.jpl.nasa.gov>
# NOTE: openlog now takes three arguments, just like openlog(3)
#
# call syslog() with a string priority and a list of printf() args
# like syslog(3)
#
# usage: require 'syslog.pl';
#
# then (put these all in a script to test function)
#
#
# do openlog($program,'cons,pid','user');
# do syslog('info','this is another test');
# do syslog('mail|warning','this is a better test: %d', time);
# do closelog();
#
# do syslog('debug','this is the last test');
# do openlog("$program $$",'ndelay','user');
# do syslog('notice','fooprogram: this is really done');
#
# $! = 55;
# do syslog('info','problem was %m'); # %m == $! in syslog(3)
package syslog;
use warnings::register;
if ($] >= 5 && warnings::enabled()) {
warnings::warn("You should 'use Sys::Syslog' instead; continuing");
}
require 'syslog.ph';
eval 'use Socket; 1' ||
eval { require "socket.ph" } ||
}
}
$maskpri = shift;
$oldmask;
}
local($priority) = shift;
local($mask) = shift;
undef $numpri;
undef $numfac;
foreach (@words) {
}
elsif ($num <= &LOG_PRIMASK) {
die "syslog: too many levels given: $_\n" if defined($numpri);
}
else {
die "syslog: too many facilities given: $_\n" if defined($numfac);
$facility = $_;
}
}
die "syslog: level must be given\n" unless defined($numpri);
if (!defined($numfac)) { # Facility not specified in this call.
}
$whoami = $1;
$mask = $2;
}
unless ($whoami) {
($whoami = getlogin) ||
($whoami = getpwuid($<)) ||
($whoami = 'syslog');
}
$mask =~ s/%m/$!/g;
if ($lo_cons) {
if ($pid = fork) {
unless ($lo_nowait) {
}
}
else {
print CONS "<$facility.$priority>$whoami: $message\r";
exit if defined $pid; # if fork failed, we're parent
close CONS;
}
}
}
}
sub xlate {
local($name) = @_;
$name = "syslog'$name";
}
sub connect {
$pat = 'S n C4 x8';
$stream = &SOCK_STREAM;
$datagram = &SOCK_DGRAM;
die "Can't lookup $myname\n" unless $name;
}
else {
}
if ($host =~ /^\d+\./) {
}
else {
die "Can't lookup $host\n" unless $name;
}
$connected = 1;
}
sub disconnect {
close SYSLOG;
$connected = 0;
}
1;