this module opens it's own handle to fd 1 or 2 instead of using the global STDOUT or STDERR
Therefore I should be able to send STDOUT/STDERR elsewhere and still use my logger object (as long as file descriptors 1 and 2 are set correctly). But this doesn't work:
use strict;
use warnings;
use Log::Dispatch;
my $log = Log::Dispatch->new(
outputs => [
[
'Screen',
min_level => 'debug',
newline => 1,
stderr => 0,
],
],
);
open my $null, '>', '/dev/null' or die "$0: /dev/null: $!\n";
open my $fd_1, '>&=', 1 or die "$0: can't fdopen 1: $!\n";
*STDOUT = *$null{IO};
print STDOUT "I don't see this\n";
print $fd_1 "this is all right\n";
$log->warning("I should see this");
https://metacpan.org/release/DROLSKY/Log-Dispatch-2.70/view/lib/Log/Dispatch/Screen.pm says:
Therefore I should be able to send STDOUT/STDERR elsewhere and still use my logger object (as long as file descriptors 1 and 2 are set correctly). But this doesn't work:
Actual output:
Expected output: