NAME
TB2::Streamer::Print - A simple streamer that prints
SYNOPSIS
use TB2::Streamer::Print;
my $streamer = TB2::Streamer::Print;
$streamer->write( out => "something something" );
$streamer->write( err => "something's wrong!" );
# Redirect out to a new filehandle.
$streamer->output_fh($fh);
DESCRIPTION
This is a TB2::Streamer which prints to a filehandle.
You are encouraged to subclass this Streamer if you're writing one which prints.
Destinations
These are the destinations understood by $streamer->write
.
out
Where normal output goes. This connects to $streamer->output_fh
.
err
Where ad-hoc user visible comments go. This connects to $streamer->error_fh
.
Attributes
output_fh
This is the filehandle for normal output. For example, TAP or XML or HTML or whatever records the test state.
Defaults to a copy of STDOUT
. This allows tests to muck around with STDOUT without it affecting test results.
error_fh
This is the filehandle for error output. This is normally human readable information about the test as its running. It is not part of the TAP or XML or HTML or whatever.
Defaults to a copy of STDERR
. This allows tests to muck around with STDERR without it affecting test results.
stdout
Contains a duplicated copy of STDOUT
. Handy for resetting the output_fh().
It is read only.
stderr
Contains a duplicated copy of STDERR
. Handy for resetting the error_fh().
It is read only.
Methods
safe_print
$streamer->safe_print($fh, @hunks);
Works like print
but is not effected by the global variables which change print's behavior such as $\
and $,
. This allows a test to play with these variables without affecting test output.
Subclasses are encouraged to take advantage of this method rather than calling print themselves.