Skip Menu |

This queue is for tickets about the Log-Log4perl CPAN distribution.

Report information
The Basics
Id: 67132
Status: resolved
Priority: 0/
Queue: Log-Log4perl

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

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



Subject: Log::Log4perl::Appender::File dies when writing undef
Basically, it boils down to the line that calls syswrite: syswrite $fh, $params{message} or die "Cannot syswrite to '$self->{filename}': $!"; This is not quite right. If the message has zero bytes to it, it will die, and $! will not be set. According to the perldoc, the correct way to do this would be: defined (syswrite $fh, $params{message}) or die "Cannot syswrite to '$self->{filename}': $!"; (parens may not be required) That is, syswrite returns undef on failure, a return of 0 merely means that syswrite wrote nothing. Another alternative would be to compare the return of syswrite to the length of the message to ensure they're the same, but that, too, gets tricky (not impossibly) in the case of undef.