Skip Menu |
 

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

Report information
The Basics
Id: 75827
Status: resolved
Priority: 0/
Queue: Sys-Syslog

People
Owner: Nobody in particular
Requestors: bthale [...] nightwing.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.29
Fixed in: 0.31



Subject: syslog() logging everything regardsless of log mask
Download (untitled) / with headers
text/plain 2.4k
When using the numeric LOG_* macros, syslog() logs every message regardless of the priority mask. use Sys::Syslog qw(:standard :macros); openlog( 'task', 'pid', LOG_USER ); setlogmask( LOG_UPTO( LOG_WARNING ) ); syslog( LOG_INFO, "This gets logged even though it shouldn't" ); The problem is the recent (0.29) addition to handle the numeric codes separately from the macro strings. My suggested patch moves the check of the log mask to follow the check to ensure than a log level was provided once the processing of the priority param is complete. Otherwise, the log mask is never consulted for numeric priority values. localhost Sys > diff --context Syslog.pm.0.29 Syslog.pm *** Syslog.pm.0.29 2012-03-16 16:08:36.080755752 -0400 --- Syslog.pm 2012-03-16 15:55:30.294696777 -0400 *************** *** 366,372 **** croak "syslog: too many levels given: $word" if defined $numpri; $numpri = $num; - return 0 unless LOG_MASK($numpri) & $maskpri; } else { croak "syslog: too many facilities given: $word" --- 366,371 ---- *************** *** 382,387 **** --- 381,389 ---- croak "syslog: level must be given" unless defined $numpri; + # Bail if the priority mask indicates we are not logging this message + return 0 unless LOG_MASK($numpri) & $maskpri; + if (not defined $numfac) { # Facility not specified in this call. $facility = 'user' unless $facility; $numfac = xlate($facility); **************************************** Sys::Syslog-0.29 Summary of my perl5 (revision 5 version 12 subversion 4) configuration: Platform: osname=linux, osvers=2.6.38-gentoo-r6, archname=x86_64-linux uname='linux fl36most01 2.6.38-gentoo-r6 #3 smp wed jul 6 20:59:19 edt 2011 x86_64 intel(r) xeon(r) cpu e5630 @ 2.53ghz genuineintel gnulinux ' Locally applied patches: 0001-gentoo_MakeMaker-RUNPATH.diff 0002-gentoo_config_over.diff 0003-gentoo_cpan_definstalldirs.diff 0004-gentoo_cpanplus_definstalldirs.diff 0005-gentoo_create-libperl-soname.diff 0006-gentoo_MakeMaker-delete_packlist.diff 0007-fixes_8d66b3f9_h2hp_fix.diff 0008-fixes_f178b03b_h2ph_using_deprecated_goto.diff 0009-gentoo_mod-paths.diff 0010-gentoo_enc2xs.diff 0011-gentoo_IO-Compress_AutoLoader_dropped_from_Compress-Zlib.diff 0012-gentoo_drop-fstack-protector.diff Built under linux
Subject: syslog.diff
Download syslog.diff
text/x-diff 859b
*** Syslog.pm.0.29 2012-03-16 16:08:36.080755752 -0400 --- Syslog.pm 2012-03-16 15:55:30.294696777 -0400 *************** *** 366,372 **** croak "syslog: too many levels given: $word" if defined $numpri; $numpri = $num; - return 0 unless LOG_MASK($numpri) & $maskpri; } else { croak "syslog: too many facilities given: $word" --- 366,371 ---- *************** *** 382,387 **** --- 381,389 ---- croak "syslog: level must be given" unless defined $numpri; + # Bail if the priority mask indicates we are not logging this message + return 0 unless LOG_MASK($numpri) & $maskpri; + if (not defined $numfac) { # Facility not specified in this call. $facility = 'user' unless $facility; $numfac = xlate($facility);
Subject: Re: [rt.cpan.org #75827] syslog() logging everything regardsless of log mask
Date: Wed, 15 Aug 2012 14:49:36 +0200
To: bug-Sys-Syslog [...] rt.cpan.org
From: Sébastien Aperghis-Tramoni <saper [...] cpan.org>
Download (untitled) / with headers
text/plain 843b
Hello, Bryan Thale wrote via RT: Show quoted text
> When using the numeric LOG_* macros, syslog() logs every message > regardless of the priority mask. > > use Sys::Syslog qw(:standard :macros); > openlog( 'task', 'pid', LOG_USER ); > setlogmask( LOG_UPTO( LOG_WARNING ) ); > syslog( LOG_INFO, "This gets logged even though it shouldn't" ); > > The problem is the recent (0.29) addition to handle the numeric codes > separately from the macro strings.
Oh, well spotted. Show quoted text
> My suggested patch moves the check of the log mask to follow the check > to ensure than a log level was provided once the processing of the > priority param is complete. Otherwise, the log mask is never consulted > for numeric priority values.
Thanks, applied. This fix will be included in Sys::Syslog 0.31. -- Sébastien Aperghis-Tramoni Close the world, txEn eht nepO.


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.