diff --git a/ddclient.in b/ddclient.in index 04c9157..e3a762a 100755 --- a/ddclient.in +++ b/ddclient.in @@ -2364,7 +2364,6 @@ sub ynu { # Takes the following keyword arguments: # * `msg` (string): The message to log. # * `label` (string): Severity ('DEBUG', 'WARNING', etc.) to prefix each line with. - # * `fh` (file handle): Where to write the log messages. # * `email` (boolean): Whether to include the message in the next email. # * `raw` (boolean): Whether to omit `label` and the contexts (output `msg` as-is). # * `ctx` (optional string): If defined, this is temporarily pushed onto the context stack @@ -2378,7 +2377,6 @@ sub ynu { my %args = ( msg => '', label => '', - fh => *STDERR, (@_ % 2) ? (msg => pop) : (), @_, ); @@ -2393,7 +2391,7 @@ sub ynu { $buffer =~ s/\n/\n$prefix/g; } $buffer .= "\n"; - print({$args{fh}} $buffer); + print(STDERR $buffer); if ($args{email}) { $emailbody .= $buffer; diff --git a/t/logmsg.pl b/t/logmsg.pl index 334bda1..f91adc0 100644 --- a/t/logmsg.pl +++ b/t/logmsg.pl @@ -2,23 +2,6 @@ use Test::More; SKIP: { eval { require Test::Warnings; } or skip($@, 1); } eval { require 'ddclient'; } or BAIL_OUT($@); -{ - my $output; - open(my $fh, '>', \$output); - local *STDERR = $fh; - ddclient::logmsg('to STDERR'); - close($fh); - is($output, "to STDERR\n", 'logs to STDERR by default'); -} - -{ - my $output; - open(my $fh, '>', \$output); - ddclient::logmsg(fh => $fh, 'to file handle'); - close($fh); - is($output, "to file handle\n", 'logs to provided file handle'); -} - my @test_cases = ( { desc => 'adds a newline', @@ -116,7 +99,10 @@ for my $tc (@test_cases) { local $ddclient::emailbody = $tc->{init_email} // ''; local $ddclient::_l = $ddclient::_l; $ddclient::_l = ddclient::pushlogctx($_) for @{$tc->{ctxs} // []}; - ddclient::logmsg(fh => $fh, @{$tc->{args}}); + { + local *STDERR = $fh; + ddclient::logmsg(@{$tc->{args}}); + } close($fh); is($output, $tc->{want}, 'output text matches'); is($ddclient::emailbody, $tc->{want_email} // '', 'email content matches');