1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
Description: fix "hostname() doesn't accept any arguments" warning
Origin: CPAN RT
Bug: https://rt.cpan.org/Public/Bug/Display.html?id=125842
Bug-Debian: https://bugs.debian.org/903741
Author: James E Keenan
Reviewed-by: gregor herrmann <gregoa@debian.org>
Last-Update: 2019-07-19
--- a/lib/Log/Handler/Output.pm
+++ b/lib/Log/Handler/Output.pm
@@ -64,7 +64,12 @@
# is that each output can have their own time/date format
# and the code which is executed can return another value.
foreach my $r (@{$self->{wanted_pattern}}) {
- $wanted->{$r->{name}} = &{$r->{code}}($self, $level);
+ unless ($r->{name} eq 'hostname') {
+ $wanted->{$r->{name}} = &{$r->{code}}($self, $level);
+ }
+ else {
+ $wanted->{$r->{name}} = $r->{code}();
+ }
}
if ($self->{message_pattern}) {
--- a/t/012-handler-message-pattern.t
+++ b/t/012-handler-message-pattern.t
@@ -1,6 +1,6 @@
use strict;
use warnings;
-use Test::More tests => 15;
+use Test::More tests => 17;
use Log::Handler;
my $CHECKED = 0;
@@ -34,7 +34,10 @@
my $log = Log::Handler->new();
-$log->add(
+ok(defined $log, "new() returned defined object");
+isa_ok($log, 'Log::Handler');
+
+my $rv = $log->add(
forward => {
forward_to => \&check_struct,
maxlevel => 'debug',
@@ -44,7 +47,7 @@
}
);
-ok(1, 'new');
+ok($rv, "add() returned true value");
$log->debug('foo');
|