Revision history for Sys-Syslog
+0.22 -- 2007.11.xx -- Sebastien Aperghis-Tramoni (SAPER)
+ [FEATURE] Added support for PERROR option.
+ [FEATURE] Support for SYSLOG on z/OS, thanks to Chun Bing Ge.
+ [CODE] Prevent $@ from being visible outside the module, in trying
+ to address the problem reported in CPAN-RT#29875.
+ [DOC] CPAN-RT#29451: Add Copyright notice. Thanks to Allison Randal
+ for her advice.
+ [DOC] New speaking about Win32 API instead of Win32 operating system.
+
0.21 -- 2007.09.14 -- Sebastien Aperghis-Tramoni (SAPER)
[BUGFIX] setlogsock(eventlog) returned true even when it shouldn't have.
- [BUGFIX] Added workaround for Mac OS X syslogd.
+ [BUGFIX] CPAN-RT#24431: Added workaround for Mac OS X syslogd.
[FEATURE] Added "pipe" mechanism in order to support HP-UX named pipe.
Thanks to H.Merijn Brand and PROCURA.
[CODE] Sys::Syslog works again on Perl 5.005, thanks to Nicholas Clark.
ndelay => 0,
nofatal => 0,
nowait => 0,
+ perror => 0,
pid => 0,
);
# use EventLog on Win32
my $is_Win32 = $^O =~ /Win32/i;
-eval "use Sys::Syslog::Win32";
-if (not $@) {
+if (eval "use Sys::Syslog::Win32; 1") {
unshift @connectMethods, 'eventlog';
} elsif ($is_Win32) {
warn $@;
}
+$@ = "";
+
my @defaultMethods = @connectMethods;
my @fallbackMethods = ();
if (eval "use Win32::EventLog; 1") {
@connectMethods = qw(eventlog);
} else {
- warnings::warnif "eventlog passed to setlogsock, but operating system isn't Win32-compatible";
+ warnings::warnif "eventlog passed to setlogsock, but no Win32 API available";
+ $@ = "";
return undef;
}
$message = @_ ? sprintf($mask, @_) : $mask;
# See CPAN-RT#24431. Opened on Apple Radar as bug #4944407 on 2007.01.21
+ # Supposedly resolved on Leopard.
chomp $message if $^O =~ /darwin/;
if ($current_proto eq 'native') {
$buf = $message;
-
}
elsif ($current_proto eq 'eventlog') {
$buf = $message;
$buf = "<$sum>$timestamp $whoami: $message\0";
}
+ # handle PERROR option
+ # "native" mechanism already handles it by itself
+ if ($options{perror} and $current_proto ne 'native') {
+ chomp $message;
+ my $whoami = $ident;
+ $whoami .= "[$$]" if $options{pid};
+ print STDERR "$whoami: $message\n";
+ }
+
# it's possible that we'll get an error from sending
# (e.g. if method is UDP and there is no UDP listener,
# then we'll get ECONNREFUSED on the send). So what we
$name = "Sys::Syslog::$name";
# Can't have just eval { &$name } || -1 because some LOG_XXX may be zero.
my $value = eval { no strict 'refs'; &$name };
- defined $value ? $value : -1;
+ $@ = "";
+ return defined $value ? $value : -1;
}
# These constants don't exist in 5.005. They were added in 1999
setsockopt(SYSLOG, IPPROTO_TCP(), TCP_NODELAY(), 1);
}
+ $@ = "";
if (!connect(SYSLOG, $addr)) {
push @$errs, "tcp connect: $!";
return 0;
return 0;
}
- if (! -S $syslog_path) {
+ if (not (-S $syslog_path or -c _)) {
push @$errs, "$syslog_path is not a socket";
return 0;
}
=item *
+C<perror> - Write the message to standard error output as well to the
+system log.
+
+=item *
+
C<pid> - Include PID with each message.
=back
mechanisms which are attempted in order.
The default is to try C<native>, C<tcp>, C<udp>, C<unix>, C<stream>, C<console>.
-Under Win32 systems, C<eventlog> will be added as the first mechanism to try
-if C<Win32::EventLog> is available.
+Under systems with the Win32 API, C<eventlog> will be added as the first
+mechanism to try if C<Win32::EventLog> is available.
Giving an invalid value for C<$sock_type> will C<croak>.
B<(F)> You gave C<setlogsock()> an invalid value for C<$sock_type>.
-=item C<eventlog passed to setlogsock, but operating system isn't Win32-compatible>
+=item C<eventlog passed to setlogsock, but no Win32 API available>
B<(W)> You asked C<setlogsock()> to use the Win32 event logger but the
operating system running the program isn't Win32 or does not provides Win32
-facilities.
+compatible facilities.
=item C<no connection to syslog available>
Please report any bugs or feature requests to
C<bug-sys-syslog (at) rt.cpan.org>, or through the web interface at
-L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Sys-Syslog>.
+L<http://rt.cpan.org/Public/Dist/Display.html?Name=Sys-Syslog>.
I will be notified, and then you'll automatically be notified of progress on
your bug as I make changes.
=back
+=head1 COPYRIGHT
+
+Copyright (C) 1990-2007 by Larry Wall and others.
+
+
=head1 LICENSE
This program is free software; you can redistribute it and/or modify it