Subject: | another bug in Log::Common |
I've found another bug in Log::Common::error(), version 1.0. In this case, $no_stderr is being ignored whenever it is used by something that isn't a CGI. This is because a '||' should be a '&&'.
First, here's code that produces the error. (Please forgive me if the formatting of any of this is messed up; I'm trying to do this via lynx.)
use Log::Common;
my $l = new Log::Common(error => "test.log", no_stderr => 1);
$l-error(message => "This shouldn't appear in STDERR, but it will");
Be sure to run this as an ordinary Perl script via the command-line to see the bug. I've included a patch below:
-- Mike F.
--- Common.pm~ Fri Jun 21 09:19:36 2002
+++ Common.pm Fri Jun 21 09:55:01 2002
@@ -55,7 +55,7 @@
# don't send the error message to STDERR if we're running as a
# CGI program, or in harness to one
- if (!defined($ENV{"GATEWAY_INTERFACE"}) || !$no_stderr) {
+ if (!defined($ENV{"GATEWAY_INTERFACE"}) && !$no_stderr) {
my $msg = "";
$msg = "$class: " if defined($class);
$msg .= $message;