summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Pfeifer <upf@de.uu.net>1997-09-05 00:00:00 +0000
committerTim Bunce <Tim.Bunce@ig.co.uk>1997-09-05 00:00:00 +0000
commitd6a06c6b3ce238e0862e09fdca0c17e9d40e9b2c (patch)
tree330c5255f8e037826365e4fda64289d58f19dd75
parent307ff3209540c536853b0a1789542a7d8a58f06d (diff)
downloadperl-d6a06c6b3ce238e0862e09fdca0c17e9d40e9b2c.tar.gz
Syslog.pm and missing _PATH_LOG
I just ran into a problem with Syslog.pm. I tried to install some modules which did call Sys::Syslog::setlogsock('unix'). The following connect fails because my syslog.ph does not define _PATH_LOG (This is SunOS 5.5.1). The easiest way to handle this would be to make setlogsock('unix') a NOOP if _PATH_LOG is not defined. I am not advocating to ignore it silently. But can we make setlogsock return a value indicating that the operation did or did not work? It seems a little cleaner that to force users to check for _PATH_LOG themselves? p5p-msgid: p5iuw1cris.fsf@knowway.de.uu.net
-rw-r--r--lib/Sys/Syslog.pm15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/Sys/Syslog.pm b/lib/Sys/Syslog.pm
index f6d9c3547e..2790e488bc 100644
--- a/lib/Sys/Syslog.pm
+++ b/lib/Sys/Syslog.pm
@@ -59,10 +59,11 @@ Sets log mask I<$mask_priority> and returns the old mask.
Sets the socket type to be used for the next call to
C<openlog()> or C<syslog()>.
-A value of 'unix' will connect to the UNIX domain socket returned
-by C<_PATH_LOG> in F<syslog.ph>. A value of 'inet' will connect
-to an INET socket returned by getservbyname().
-Any other value croaks.
+A value of 'unix' will connect to the UNIX domain socket returned by
+C<_PATH_LOG> in F<syslog.ph>. If F<syslog.ph> fails to define
+C<_PATH_LOG>, C<setlogsock> returns C<undef>; otherwise a true value is
+returned. A value of 'inet' will connect to an INET socket returned by
+getservbyname(). Any other value croaks.
The default is for the INET socket to be used.
@@ -135,12 +136,18 @@ sub setlogmask {
sub setlogsock {
local($setsock) = shift;
if (lc($setsock) eq 'unix') {
+ if (defined &_PATH_LOG) {
+ $sock_unix = 1;
+ } else {
+ return;
+ }
$sock_unix = 1;
} elsif (lc($setsock) eq 'inet') {
undef($sock_unix);
} else {
croak "Invalid argument passed to setlogsock; must be 'unix' or 'inet'";
}
+ return 1;
}
sub syslog {