---
name: "Test2::Formatter::Test2::Composer"
section: "3pm"
platform: "linux"
package: "libtest2-harness-perl"
version: "1.000158-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Test2::Formatter::Test2::Composer"
---

# Test2::Formatter::Test2::Composer(3pm)

Compose output components from event facets

## NAME

Test2::Formatter::Test2::Composer - Compose output components from event facets

## DESCRIPTION

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.

## SYNOPSIS

```
    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;
        ...,
    }
```

## METHODS

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.

- $inst = $class-\>**new()**

  Create a blessed instance. This is here for convenience only. All methods are class methods.

- $arrayref = $class-\>render\_one\_line($event)

  - $arrayref = $class-\>render\_one\_line(\\%facet\_data)

  ```
      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:

  - Custom 'render' facet

    - Control 'halt' facet (bail-out)

    - Assertion (pass/fail)

    - Error message

    - Plan

    - Info (note/diag)

    - Timing data

    - About

    - @lines = $class-\>render\_verbose($event, %control\_params)

  - @lines = $class-\>render\_verbose(\\%facet\_data, %control\_params)

  This will verbosely render any event. The `%control_params` are passed directly to `render_control()` and are not used for anything else.

  ```
      for my $line ($comp->render_verbose($event)) {
          my ($facet_name, $tag_string, $text_for_humans) = @$line;
          ...,
      }
  ```

- @lines = $class-\>render\_super\_verbose($event)

  - @lines = $class-\>render\_super\_verbose(\\%facet\_data)

  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.

  This is mainly useful for tools that allow deep inspection of log files.

### FACET RENDERERS

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]"`.

- @lines = $class-\>render\_control(\\%facet\_data, super\_verbose =\> $bool)

  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.

- @lines = $class-\>render\_launch(\\%facet\_data)

  - @lines = $class-\>render\_start(\\%facet\_data)

  - @lines = $class-\>render\_exit(\\%facet\_data)

  - @lines = $class-\>render\_end(\\%facet\_data)

  - @lines = $class-\>render\_brief(\\%facet\_data)

  - @lines = $class-\>render\_plan(\\%facet\_data)

  - @lines = $class-\>render\_assert(\\%facet\_data)

  - @lines = $class-\>render\_amnesty(\\%facet\_data)

  - @lines = $class-\>render\_debug(\\%facet\_data)

  - @lines = $class-\>render\_info(\\%facet\_data)

  - @lines = $class-\>render\_about(\\%facet\_data)

  - @lines = $class-\>render\_errors(\\%facet\_data)

  ## SOURCE

The source code repository for Test2-Harness can be found at *http://github.com/Test-More/Test2-Harness/*.

## MAINTAINERS

- Chad Granum \<exodist@cpan.org\>

  ## AUTHORS

- Chad Granum \<exodist@cpan.org\>

  ## COPYRIGHT

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/*
