Test2::Formatter::Test2::Composer - Compose output components from event facets
This is used by Test2::Formatter::Test2 to turn events into output components. This logic lives here instead of in the formatter because it is also used by Test2::Harness::UI. Other tools may also find this conversion useful.
use Test2::Formatter::Test2::Composer; # Note, all methods are class methods, this is just here for convenience. my $comp = Test2::Formatter::Test2::Composer->new(); my $out = $comp->render_one_line($event); my ($facet_name, $tag_string, $text_for_humans) = @$out; ... for my $line ($comp->render_verbose($event)) { my ($facet_name, $tag_string, $text_for_humans) = @$line; ..., }
All methods are class methods, but they also work just fine on a blessed instance. There is no benefit to a blessed instance, but you can create one for convenience if it makes you more comfortable.
Create a blessed instance. This is here for convenience only. All methods are class methods.
my $out = $comp->render_one_line($event); my ($facet_name, $tag_string, $text_for_humans) = @$out;
This will return a single line of output from the event, even if the event would normally return multiple lines.
In order of priority:
This will verbosely render any event. The %control_params are passed directly to render_control() and are not used for anything else.
%control_params
render_control()
for my $line ($comp->render_verbose($event)) { my ($facet_name, $tag_string, $text_for_humans) = @$line; ..., }
This is even more verbose than render_verbose() because it produces output lines even for facets that should normally not be seen, things that would usually be considered noise.
render_verbose()
This is mainly useful for tools that allow deep inspection of log files.
With exception of render_control() these are all the same. These all take \%facet_data as their only argument, and return a list of line-arrayrefs [$facet, $tag, $text_for_humans].
\%facet_data
[$facet, $tag, $text_for_humans]
This specific one is special in that it can take an extra argument. This argument is used to toggle between super_verbose and regular verbosity. No other facet renderer needs this toggle. If omitted it defaults to not being super verbose.
The source code repository for Test2-Harness can be found at http://github.com/Test-More/Test2-Harness/.
Copyright 2020 Chad Granum <exodist7@gmail.com>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://dev.perl.org/licenses/
To install Test2::Harness, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test2::Harness
CPAN shell
perl -MCPAN -e shell install Test2::Harness
For more information on module installation, please visit the detailed CPAN module installation guide.