Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sys::Syslog (5.6.1) - Cannot use LOG_EMERG #6052

Closed
p5pRT opened this issue Nov 1, 2002 · 3 comments
Closed

Sys::Syslog (5.6.1) - Cannot use LOG_EMERG #6052

p5pRT opened this issue Nov 1, 2002 · 3 comments

Comments

@p5pRT
Copy link

p5pRT commented Nov 1, 2002

Migrated from rt.perl.org#18190 (status was 'resolved')

Searchable as RT18190$

@p5pRT
Copy link
Author

p5pRT commented Nov 1, 2002

From paul@infointeractive.com

In Sys​::Syslog, you cannot use LOG_EMERG (or 'emerg', etc). Doing so
results in the following error​:

syslog​: invalid level/facility​: LOG_EMERG at yadayada.pl line 275

The problem is in Sys​::Syslog​::xlate()

sub xlate {
  local($name) = @​_;
  $name = uc $name;
  $name = "LOG_$name" unless $name =~ /^LOG_/;
  $name = "Sys​::Syslog​::$name";
  eval { &$name } || -1;
}

In the last line, &$name evaluates to 0, via the AUTOLOAD sub, which is the
correct integer value of LOG_EMERG, and so the subroutine returns -1. In
our Perl 5.005_03 installation, the xlate() sub looks like this​:

sub xlate {
  local($name) = @​_;
  $name = uc $name;
  $name = "LOG_$name" unless $name =~ /^LOG_/;
  $name = "Sys​::Syslog​::$name";
  defined &$name ? &$name : -1;
}

This implementation works correctly, and returns the value 0 for LOG_EMERG.

Paul


Paul Medynski Senior Software Engineer
InfoInterActive Corp. An AOL Company
Voice (613) 738-3731 Fax (902) 832-1015
ICQ [21033521] AIM [PaulFMedynski]
www.infointeractive.com www.internetcallmanager.com

@p5pRT
Copy link
Author

p5pRT commented Nov 3, 2002

From @rgs

Paul Medynski wrote​:

In Sys​::Syslog, you cannot use LOG_EMERG (or 'emerg', etc). Doing so
results in the following error​:

syslog​: invalid level/facility​: LOG_EMERG at yadayada.pl line 275

Thanks for your report (and your correct analysis thereof).
This problem appears to have been corrected in perl 5.8.0, where the xlate()
function is :

sub xlate {
  local($name) = @​_;
  $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 { &$name };
  defined $value ? $value : -1;
}

The problem is in Sys​::Syslog​::xlate()

sub xlate {
local($name) = @​_;
$name = uc $name;
$name = "LOG_$name" unless $name =~ /^LOG_/;
$name = "Sys​::Syslog​::$name";
eval { &$name } || -1;
}

In the last line, &$name evaluates to 0, via the AUTOLOAD sub, which is the
correct integer value of LOG_EMERG, and so the subroutine returns -1. In
our Perl 5.005_03 installation, the xlate() sub looks like this​:

sub xlate {
local($name) = @​_;
$name = uc $name;
$name = "LOG_$name" unless $name =~ /^LOG_/;
$name = "Sys​::Syslog​::$name";
defined &$name ? &$name : -1;
}

This implementation works correctly, and returns the value 0 for LOG_EMERG.

@p5pRT
Copy link
Author

p5pRT commented Nov 5, 2002

@rspier - Status changed from 'new' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant