Skip Menu |
 

This queue is for tickets about the Logger-Syslog CPAN distribution.

Report information
The Basics
Id: 23499
Status: open
Priority: 0/
Queue: Logger-Syslog

People
Owner: Nobody in particular
Requestors: SAPER [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.0
Fixed in: (no value)



Subject: [PATCH] setlogsock() usage is discouraged
Download (untitled) / with headers
text/plain 700b
Hello, Attached is a patch to remove the calls to setlogsock(), which is discouraged because it goes against portability: you're selecting the "unix" mechanism without knowing whether it's available on the system or not, while Sys::Syslog will by default use the first available mechanism. The direct benefits of *not* using setlogsock() is that you'll get better mechanisms support with recent Sys::Syslog versions. Since version 0.16, the "native" mechanism (i.e. using direct calls to the C functions instead of connecting to a socket) is used by default on Unix systems, and version 0.19 will work on Win32 by sending messages to the event log. Regards -- Close the world, txEn eht nepO.
Subject: Logger-Syslog-1.0-nosetlogsock.diff
diff -ru Logger-Syslog-1.0-orig/lib/Logger/Syslog.pm Logger-Syslog-1.0/lib/Logger/Syslog.pm --- Logger-Syslog-1.0-orig/lib/Logger/Syslog.pm 2006-11-17 10:25:36.000000000 +0100 +++ Logger-Syslog-1.0/lib/Logger/Syslog.pm 2006-11-20 09:53:24.938521376 +0100 @@ -73,7 +73,7 @@ use strict; use warnings; use Carp; -use Sys::Syslog qw(:DEFAULT setlogsock); +use Sys::Syslog; use File::Basename; sub __get_script_name(); @@ -84,7 +84,6 @@ # If we're not under mod_perl, let's open the Syslog socket. if (! defined $ENV{'MOD_PERL'}) { eval { - setlogsock('unix'); openlog($basename, 'pid', $DEFAULT_FACILITY); }; } @@ -100,7 +99,6 @@ { return unless $ENV{'MOD_PERL'}; eval { - setlogsock('unix'); $basename = basename($ENV{'SCRIPT_FILENAME'}); $fullname = __get_script_name(); openlog($basename, 'pid', $DEFAULT_FACILITY);
Download (untitled) / with headers
text/plain 680b
I'm using a custom version of this module. When I remove setlogsock, and I log an emergency event, my terminal doesn't return to a prompt unless I press enter. I don't know if it works around the portability issue, but I wrapped the setlogsock call with: if ( $^O ne 'MSWin32' ) { ... } . I haven't tested it. I also added the ability to call the syslog severity levels what they're called, and their full names. I added: * "critical" to "crit" ("critic" isn't really a severity level) * "informational" to "info"). * "emerg" and "emergency" I've only tested this in a linux shell environment. Patch attached. I've also added the file I'm using to test on the command line.
Subject: 2018-01-07-LoggerSyslog-a.patch
--- /home/mvanwinkle/src/mvanwinkleias_github/ias_perl_script_infra/src/lib/perl5/Logger/Syslog.pm 2017-12-31 20:30:24.726432863 -0500 +++ Logger/Syslog.pm 2018-01-07 13:14:52.870359199 -0500 @@ -18,8 +18,31 @@ Logger::Syslog takes care of everything regarding the Syslog communication, all you have to do is to use the function you need to send a message to syslog. -Logger::Syslog provides one function per Syslog message level: debug, info, -warning, error, notice, critic, alert. +Logger::Syslog provides functions for each Syslog message level: + +=over 4 + +=item debug + +=item info, informational + +=item warning + +=item err, error + +=item notice + +=item crit, critic, critical + +=item alert + +=item emerg, emergency + +=back + +The left most name (for example, example, 'crit') is what's passed to syslog. + +The right most name is the full english word. =head1 NOTES @@ -40,7 +63,7 @@ } ... notice("There something to notify"); - + =cut BEGIN { @@ -50,12 +73,14 @@ @ISA = ( 'Exporter' ) ; @EXPORT = qw ( &debug - &info + &informational &notice &warning &error - &critic + &critical &alert + &emergency + &logger_prefix &logger_close &logger_init @@ -96,7 +121,10 @@ $facility = $DEFAULT_FACILITY unless defined $facility; eval { - setlogsock('unix'); + if ( $^O ne 'MSWin32' ) + { + setlogsock('unix'); + } $fullname = __get_script_name(); openlog($fullname, 'pid', $facility); logger_prefix(""); @@ -135,7 +163,7 @@ messages sent to syslog. Example: - + logger_prefix("my program"); info("starting"); ... @@ -159,7 +187,8 @@ warning => 'warn ', debug => 'debug', crit => 'crit ', - alert => 'alert' + alert => 'alert', + emerg => 'emerg', ); @@ -215,13 +244,28 @@ return if ($AUTOLOAD eq 'DESTROY'); return 0 unless defined $message and length $message; - my @supported = qw(debug info warning err error notice alert crit critic); + my @supported = qw( + debug + info informational + warning + err error + notice + alert + crit critic critical + emerg emergency + ); if (grep /^$AUTOLOAD$/, @supported) { my $level = $AUTOLOAD; + $level = 'info' if ($level eq 'informational'); + $level = 'err' if ($level eq 'error'); + $level = 'crit' if ($level eq 'critic'); + $level = 'crit' if ($level eq 'critical'); + + $level = 'emerg' if ($level eq 'emergency'); log_with_syslog($level, $message); }
Subject: syslog_perl.pl
Download syslog_perl.pl
text/x-perl 714b
#!/usr/bin/perl use strict; use warnings; use lib './'; use Logger::Syslog(); # Logger::Syslog:: Logger::Syslog::debug("Debug message"); Logger::Syslog::alert("Alert message"); Logger::Syslog::info("Info message"); Logger::Syslog::informational("Informational message"); Logger::Syslog::notice("Notice message"); Logger::Syslog::warning("Warning message"); Logger::Syslog::err("Err message"); Logger::Syslog::error("Error message"); Logger::Syslog::crit("Crit message"); Logger::Syslog::critic("Critic message"); Logger::Syslog::critical("Critical message"); Logger::Syslog::emerg("Emerg message"); Logger::Syslog::emergency("Emergency message"); Logger::Syslog::debug("exiting."); print "Exiting.\n";


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.