Test2::Formatter::Test2::Composer(3pm) | User Contributed Perl Documentation | Test2::Formatter::Test2::Composer(3pm) |
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.
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:
for my $line ($comp->render_verbose($event)) { my ($facet_name, $tag_string, $text_for_humans) = @$line; ..., }
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]".
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/
2023-03-12 | perl v5.36.0 |