From: Rafael Garcia-Suarez Date: Tue, 20 Jun 2006 22:01:16 +0000 (+0000) Subject: Upgrade to Sys::Syslog 0.16 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8edeb3adf78562499e1eeea00d9ecf5f58e8de2d;p=p5sagit%2Fp5-mst-13.2.git Upgrade to Sys::Syslog 0.16 p4raw-id: //depot/perl@28410 --- diff --git a/ext/Sys/Syslog/Changes b/ext/Sys/Syslog/Changes index ce33e19..abc07df 100644 --- a/ext/Sys/Syslog/Changes +++ b/ext/Sys/Syslog/Changes @@ -1,7 +1,18 @@ Revision history for Sys-Syslog +0.16 -- 2006.06.20 -- Sebastien Aperghis-Tramoni (SAPER) + [BUGFIX] Perl-RT#20557: Save errno before trying to connect. + [FEATURE] Perl-RT#35406: Applied the patch proposed by Keisuke Hirata + for a more lax handling of "stream" or "unix" path. + [FEATURE] Now try the "native" mechanism first. + [TESTS] Silence warnings generated by t/syslog.t in Perl 5.8.8 and + later. + [DOC] Added documentation about the "native" mechanism. + [DOC] Now indicates whether tickets are from CPAN or Perl RT. + + 0.15 -- 2006.06.10 -- Sebastien Aperghis-Tramoni (SAPER) - [FEATURE] RT#17316: Added a "nofatal" option to openlog(). + [FEATURE] CPAN-RT#17316: Added a "nofatal" option to openlog(). [FEATURE] Sys::Syslog warnings can now be controled by the warnings category of the same name. [FEATURE] Added support for using the native C syslog(3) functions. @@ -10,13 +21,13 @@ Revision history for Sys-Syslog parentheses. 0.14 -- 2006.05.25 -- Sebastien Aperghis-Tramoni (SAPER) - [BUGFIX] RT#19259, RT#17518: Now allowing all levels and facilities. + [BUGFIX] CPAN-RT#19259, #17518: Now allowing all levels and facilities. [CODE] Removed useless "&". [CODE] Improved readability by adding empty lines and reworking the code here and there. [CODE] Added new macros from Mac OS X. [TESTS] Added more tests in order to increase coverage. - [DOC] RT#19085: Corrected errors in the documentation for setlogmask(). + [DOC] CPAN-RT#19085: Corrected errors in the documentation for setlogmask(). [DOC] Added several links to online manual pages, RFCs and articles. [DOC] Corrected minor things in Changes. @@ -29,9 +40,9 @@ Revision history for Sys-Syslog use INADDR_LOOPBACK. [CODE] Merged blead@26772: $host needs to stay in case the user sets it. [CODE] Merged blead@26773: check that $syslog_path is a socket. - [TESTS] RT#16980 (Alan Burlison): Sys::Syslog blows up rather + [TESTS] CPAN-RT#16980 (Alan Burlison): Sys::Syslog blows up rather spectacularly on Solaris. Corrected by previous patches. - [TESTS] RT#16974: Failed test in t/podspell. This test is now skipped. + [TESTS] CPAN-RT#16974: Failed test in t/podspell. This test is now skipped. 0.12 -- 2006.01.07 -- Sebastien Aperghis-Tramoni (SAPER) [DOC] Added a link to an article about Sys::Syslog. @@ -48,7 +59,7 @@ Revision history for Sys-Syslog [FEATURE] Support for three Exporter tags. [FEATURE] XSLoader is now optional. [CODE] No longer "use"s Sys::Hostname as it was "require"d where needed. - [CODE] RT#16604: Use local timestamp. + [CODE] CPAN-RT#16604: Use local timestamp. [DIST] Merged blead@26343: Fix realclean target. [DOC] Improved documentation. [TESTS] Added more tests to t/syslog.t in order to increase code coverage. diff --git a/ext/Sys/Syslog/Syslog.pm b/ext/Sys/Syslog/Syslog.pm index fe75005..a5bad2e 100644 --- a/ext/Sys/Syslog/Syslog.pm +++ b/ext/Sys/Syslog/Syslog.pm @@ -8,7 +8,7 @@ require 5.006; require Exporter; { no strict 'vars'; - $VERSION = '0.15'; + $VERSION = '0.16'; @ISA = qw(Exporter); %EXPORT_TAGS = ( @@ -73,7 +73,7 @@ my %options = ( # it would be nice to try stream/unix first, since that will be # most efficient. However streams are dodgy - see _syslog_send_stream -my @connectMethods = ( 'tcp', 'udp', 'unix', 'stream', 'console' ); +my @connectMethods = qw(native tcp udp unix stream console); if ($^O =~ /^(freebsd|linux)$/) { @connectMethods = grep { $_ ne 'udp' } @connectMethods; } @@ -156,8 +156,8 @@ sub setlogsock { } } elsif (lc $setsock eq 'unix') { - if (length _PATH_LOG() && !defined $syslog_path) { - $syslog_path = _PATH_LOG(); + if (length _PATH_LOG() || (defined $syslog_path && -w $syslog_path)) { + $syslog_path = _PATH_LOG() unless defined $syslog_path; @connectMethods = ( 'unix' ); } else { warnings::warnif 'unix passed to setlogsock, but path not available'; @@ -203,18 +203,19 @@ sub syslog { my (@words, $num, $numpri, $numfac, $sum); my $failed = undef; my $fail_time = undef; + my $error = $!; my $facility = $facility; # may need to change temporarily. croak "syslog: expecting argument \$priority" unless defined $priority; croak "syslog: expecting argument \$format" unless defined $mask; - @words = split(/\W+/, $priority, 2);# Allow "level" or "level|facility". + @words = split(/\W+/, $priority, 2); # Allow "level" or "level|facility". undef $numpri; undef $numfac; foreach (@words) { - $num = xlate($_); # Translate word to number. + $num = xlate($_); # Translate word to number. if ($num < 0) { croak "syslog: invalid level/facility: $_" } @@ -240,11 +241,10 @@ sub syslog { connect_log() unless $connected; if ($mask =~ /%m/) { - my $err = $!; # escape percent signs if sprintf will be called - $err =~ s/%/%%/g if @_; + $error =~ s/%/%%/g if @_; # replace %m with $err, if preceded by an even number of percent signs - $mask =~ s/(? on failure. A value of C<"unix"> will connect to the UNIX domain socket (in some systems a character special device) returned by the C<_PATH_LOG> macro (if your system defines it), or F or F, -whatever is writable. A value of 'stream' will connect to the stream +whatever is writable. A value of C<"stream"> will connect to the stream indicated by the pathname provided as the optional second parameter. (For example Solaris and IRIX require C<"stream"> instead of C<"unix">.) +A value of C<"native"> will use the native C functions from your C +library. A value of C<"inet"> will connect to an INET socket (either C or C, tried in that order) returned by C. C<"tcp"> and C<"udp"> can also be given as values. The value C<"console"> will send messages diff --git a/ext/Sys/Syslog/t/syslog.t b/ext/Sys/Syslog/t/syslog.t index 030a0eb..76353e9 100755 --- a/ext/Sys/Syslog/t/syslog.t +++ b/ext/Sys/Syslog/t/syslog.t @@ -14,6 +14,7 @@ use Test::More; # we enable all Perl warnings, but we don't "use warnings 'all'" because # we want to disable the warnings generated by Sys::Syslog +no warnings; use warnings qw(closure deprecated exiting glob io misc numeric once overflow pack portable recursion redefine regexp severe signal substr syntax taint uninitialized unpack untie utf8 void);