Subject: | Sys::Syslog fails for unknown reasons. |
Date: | Fri, 18 Apr 2008 16:56:09 +0200 |
To: | bug-Sys-Syslog [...] rt.cpan.org |
From: | David Verdin <david.verdin [...] cru.fr> |
Hi,
I am one of the developers of the mailing list manager Sympa
(http://www.sympa.org). It is entirely written in perl.
We recently added a control over our logs so that, if a log fail, the
server administrator is warned.
Some users updated their version of Sys:Syslog to the latest (0.24) and
reported that they received a considerable amount of warning regarding
failures to log with the error:
syslog: invalid level/facility: info at /home/sympa/bin/Log.pm line 101
This also happens with the "notice" facility. No other facility is
concerned.
That's when we found that, sometimes, the xlate function of Sys::Syslog
seems to be failing to return the correct value. It is hard to determine
the exact causes, but I can describe the main symptoms:
I added some traces in xlate:
# xlate()
# -----
# private function to translate names to numeric values
#
sub xlate {
my($name) = @_;
return $name+0 if $name =~ /^\s*\d+\s*$/;
$name = uc $name;
$name = "LOG_$name" unless $name =~ /^LOG_/;
$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 };
open DUMP, ">>/tmp/out";
print DUMP
"###########################################################\n";
print DUMP "name: $name\n";
print DUMP "value: $value\n";
print DUMP "error:$@\n";
close DUMP;
$@ = "";
return defined $value ? $value : -1;
}
And this is some of the output I obtained when launchin the sympa.pl
script (see attached file):
###########################################################
name: Sys::Syslog::LOG_ERR
value: 3
error:
###########################################################
name: Sys::Syslog::LOG_INFO
value:
error:Bizarre copy of CODE in leavesub at
/usr/lib/perl5/5.8.8/i386-linux-thread-multi/Sys/Syslog.pm line 474.
###########################################################
name: Sys::Syslog::LOG_INFO
value:
error:Bizarre copy of CODE in leavesub at
/usr/lib/perl5/5.8.8/i386-linux-thread-multi/Sys/Syslog.pm line 474.
###########################################################
name: Sys::Syslog::LOG_ERR
value: 3
error:
###########################################################
name: Sys::Syslog::LOG_LOCAL5
value: 168
error:
###########################################################
name: Sys::Syslog::LOG_INFO
value:
error:Bizarre copy of CODE in leavesub at
/usr/lib/perl5/5.8.8/i386-linux-thread-multi/Sys/Syslog.pm line 474.
###########################################################
name: Sys::Syslog::LOG_NOTICE
value: 5
error:
###########################################################
name: Sys::Syslog::LOG_LOCAL5
value: 168
error:
###########################################################
name: Sys::Syslog::LOG_NOTICE
value: 5
error:
###########################################################
name: Sys::Syslog::LOG_LOCAL5
value: 168
error:
###########################################################
name: Sys::Syslog::LOG_INFO
value:
error:Bizarre copy of CODE in leavesub at
/usr/lib/perl5/5.8.8/i386-linux-thread-multi/Sys/Syslog.pm line 474.
###########################################################
name: Sys::Syslog::LOG_NOTICE
value: 5
error:
###########################################################
name: Sys::Syslog::LOG_LOCAL5
value: 168
error:
So this is the elements I have:
1- the error happens with "info" and "notice" log levels only;
2- The error is not systematic. in the previous output, some logs with
the level "notice" work and other don't.
3- in Sympa, the logs are handled through a specialized module, Log.pm
(attached) which is called in the Sympa dameons by the line "use Log;".
This module imports Sys::syslog with the line "use Sys::Syslog;".
4- A simple script just calling ths syslog function doesn't give any
bad result. The logs are performed without any problem.
5- It looks like the "eval { no strict 'refs'; &$name }" doesn't always
work and it is probably related to the way we import the Syslog module.
But I have no clue what exactly this line is supposed to do. I suppose
that it returns the indice of the entry containing the value of the log
level in the array corresponding to the "macros" export tag. Bu I must
admit that what you wrote is far beyond my comprehension of perl. I
really don't know what happens when you evaluates "&$name".
So do you have any clue about what's happening and how it is possible
that, in the same script, we can successively fail and succeed in
recognizing the log level?
Regards,
--
David Verdin
Comité réseau des universités
Message body is not shown because it is too large.
Message body is not shown because it is too large.