log all mtr output in vardir/log/stdout.log
despite the name, it logs both stdout and stderr
This commit is contained in:
parent
50359719f0
commit
5d8ac1ece1
@ -186,8 +186,10 @@ sub create_process {
|
|||||||
# it and any childs(that hasn't changed group themself)
|
# it and any childs(that hasn't changed group themself)
|
||||||
setpgrp(0,0) if $opts{setpgrp};
|
setpgrp(0,0) if $opts{setpgrp};
|
||||||
|
|
||||||
if ( $output and !open(STDOUT, $open_mode, $output) ) {
|
if ( $output ) {
|
||||||
croak("can't redirect STDOUT to '$output': $!");
|
close STDOUT;
|
||||||
|
open(STDOUT, $open_mode, $output)
|
||||||
|
or croak "can't redirect STDOUT to '$output': $!";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $error ) {
|
if ( $error ) {
|
||||||
@ -196,8 +198,10 @@ sub create_process {
|
|||||||
croak("can't dup STDOUT: $!");
|
croak("can't dup STDOUT: $!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elsif ( ! open(STDERR, $open_mode, $error) ) {
|
else {
|
||||||
croak("can't redirect STDERR to '$error': $!");
|
close STDERR;
|
||||||
|
open(STDERR, $open_mode, $error)
|
||||||
|
or croak "can't redirect STDERR to '$error': $!";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
23
mysql-test/lib/My/Tee.pm
Normal file
23
mysql-test/lib/My/Tee.pm
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
package My::Tee;
|
||||||
|
|
||||||
|
# see PerlIO::via
|
||||||
|
|
||||||
|
our $copyfh;
|
||||||
|
|
||||||
|
sub PUSHED
|
||||||
|
{
|
||||||
|
open($copyfh, '>', "$::opt_vardir/log/stdout.log")
|
||||||
|
or die "open(>$::opt_vardir/log/stdout.log): $!"
|
||||||
|
unless $copyfh;
|
||||||
|
bless { }, shift;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub WRITE
|
||||||
|
{
|
||||||
|
my ($obj, $buf, $fh) = @_;
|
||||||
|
print $fh $buf;
|
||||||
|
print $copyfh $buf;
|
||||||
|
return length($buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
@ -91,6 +91,7 @@ use My::Platform;
|
|||||||
use My::SafeProcess;
|
use My::SafeProcess;
|
||||||
use My::ConfigFactory;
|
use My::ConfigFactory;
|
||||||
use My::Options;
|
use My::Options;
|
||||||
|
use My::Tee;
|
||||||
use My::Find;
|
use My::Find;
|
||||||
use My::SysInfo;
|
use My::SysInfo;
|
||||||
use My::CoreDump;
|
use My::CoreDump;
|
||||||
@ -392,6 +393,11 @@ sub main {
|
|||||||
initialize_servers();
|
initialize_servers();
|
||||||
init_timers();
|
init_timers();
|
||||||
|
|
||||||
|
unless (IS_WINDOWS) {
|
||||||
|
binmode(STDOUT,":via(My::Tee)") or die "binmode(STDOUT, :via(My::Tee)):$!";
|
||||||
|
binmode(STDERR,":via(My::Tee)") or die "binmode(STDERR, :via(My::Tee)):$!";
|
||||||
|
}
|
||||||
|
|
||||||
mtr_report("Checking supported features...");
|
mtr_report("Checking supported features...");
|
||||||
|
|
||||||
executable_setup();
|
executable_setup();
|
||||||
@ -6280,7 +6286,8 @@ sub xterm_stat {
|
|||||||
my $done = $num_tests - $left;
|
my $done = $num_tests - $left;
|
||||||
my $spent = time - $^T;
|
my $spent = time - $^T;
|
||||||
|
|
||||||
printf "\e];mtr: spent %s on %d tests. %s (%d tests) left\a",
|
syswrite STDOUT, sprintf
|
||||||
|
"\e];mtr: spent %s on %d tests. %s (%d tests) left\a",
|
||||||
time_format($spent), $done,
|
time_format($spent), $done,
|
||||||
time_format($spent/$done * $left), $left;
|
time_format($spent/$done * $left), $left;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user