<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package TAP::Formatter::Console;

use strict;
use warnings;
use base 'TAP::Formatter::Base';
use POSIX qw(strftime);

=head1 NAME

TAP::Formatter::Console - Harness output delegate for default console output

=head1 VERSION

Version 3.48

=cut

our $VERSION = '3.48';

=head1 DESCRIPTION

This provides console orientated output formatting for TAP::Harness.

=head1 SYNOPSIS

 use TAP::Formatter::Console;
 my $harness = TAP::Formatter::Console-&gt;new( \%args );

=head2 C&lt;&lt; open_test &gt;&gt;

See L&lt;TAP::Formatter::Base&gt;

=cut

sub open_test {
    my ( $self, $test, $parser ) = @_;

    my $class
      = $self-&gt;jobs &gt; 1
      ? 'TAP::Formatter::Console::ParallelSession'
      : 'TAP::Formatter::Console::Session';

    eval "require $class";
    $self-&gt;_croak($@) if $@;

    my $session = $class-&gt;new(
        {   name       =&gt; $test,
            formatter  =&gt; $self,
            parser     =&gt; $parser,
            show_count =&gt; $self-&gt;show_count,
        }
    );

    $session-&gt;header;

    return $session;
}

# Use _colorizer delegate to set output color. NOP if we have no delegate
sub _set_colors {
    my ( $self, @colors ) = @_;
    if ( my $colorizer = $self-&gt;_colorizer ) {
        my $output_func = $self-&gt;{_output_func} ||= sub {
            $self-&gt;_output(@_);
        };
        $colorizer-&gt;set_color( $output_func, $_ ) for @colors;
    }
}

sub _failure_color {
    my ($self) = @_;

    return $ENV{'HARNESS_SUMMARY_COLOR_FAIL'} || 'red';
}

sub _success_color {
    my ($self) = @_;

    return $ENV{'HARNESS_SUMMARY_COLOR_SUCCESS'} || 'green';
}

sub _output_success {
    my ( $self, $msg ) = @_;
    $self-&gt;_set_colors( $self-&gt;_success_color() );
    $self-&gt;_output($msg);
    $self-&gt;_set_colors('reset');
}

sub _failure_output {
    my $self = shift;
    $self-&gt;_set_colors( $self-&gt;_failure_color() );
    my $out = join '', @_;
    my $has_newline = chomp $out;
    $self-&gt;_output($out);
    $self-&gt;_set_colors('reset');
    $self-&gt;_output($/)
      if $has_newline;
}

1;
</pre></body></html>