Test2::...::Trace(3pm)
π NAME π
Test2::EventFacet::Trace β Debug information for events.
And yes bestie, you're on the Test2::...::Trace(3pm) page from the Perl Programmers Reference Guide. Buckle up, it's giving debug-info realness π
β¨ DESCRIPTION β¨
Okay so the Test2::API::Context object β and literally all Test2::Event types β need access to info about where they were created. This object is that info. Main character energy for trace data π
π SYNOPSIS π
use Test2::EventFacet::Trace;
my $trace = Test2::EventFacet::Trace->new(
frame => [$package, $file, $line, $subname],
);
π¦ FACET FIELDS π¦
These are the fields, no cap:
$string = $trace->{details}/$string = $trace->details()β this is your custom trace message, and it gets used INSTEAD ofat <FILE> line <LINE>when you call$trace->debug.$frame = $trace->{frame}/$frame = $trace->frame()β gets the call frame arrayref. It looks like this:
[$package, $file, $line, $subname]
$int = $trace->{pid}/$int = $trace->pid()β the process ID in which the event was generated.$int = $trace->{tid}/$int = $trace->tid()β the thread ID in which the event was generated.$id = $trace->{cid}/$id = $trace->cid()β the ID of the context that was used to create the event.$uuid = $trace->{uuid}/$uuid = $trace->uuid()β the UUID of the context that was used to create the event. (If uuid tagging was enabled.)($pkg, $file, $line, $subname) = $trace->callβ get the basic call info as a list.@caller = $trace->full_callβ get the fullcaller(N)results.$warning_bits = $trace->warning_bitsβ get index 9 from the full caller info. This is thewarnings_bitsfield.
The value of this is not portable across perl versions or even processes. However it can be used in the process that generated it to reproduce the warnings settings in a new scope.
eval <<EOT;
BEGIN { ${^WARNING_BITS} = $trace->warning_bits };
... context's warning settings apply here ...
EOT
π DISCOURAGED HUB RELATED FIELDS π
Okay so these fields were not always set properly by tools. These are MOSTLY deprecated by the Test2::EventFacet::Hub facets. These fields are not required, and may only reflect the hub that was current when the event was created, which is not necessarily the same as the hub the event was sent through.
Some tools did do a good job setting these to the correct hub, but you cannot always rely on that. Use the 'hubs' facet list instead, bestie.
$hid = $trace->{hid}/$hid = $trace->hid()β the ID of the hub that was current when the event was created.$huuid = $trace->{huuid}/$huuid = $trace->huuid()β the UUID of the hub that was current when the event was created. (If uuid tagging was enabled).$int = $trace->{nested}/$int = $trace->nested()β how deeply nested the event is.$bool = $trace->{buffered}/$bool = $trace->buffered()β true if the event was buffered and not sent to the formatter independent of a parent. (This should never be set whennestedis0or"undef").
π METHODS π
Note: all facet frames are also methods. Slay.
$trace->set_detail($msg)/$msg = $trace->detailβ get/set a custom trace message that will be used INSTEAD ofat <FILE> line <LINE>when calling$trace->debug.
detail() is an alias to the "details" facet field for backwards compatibility.
$str = $trace->debugβ typically returns the stringat <FILE> line <LINE>. Ifdetailis set, then its value will be returned instead.$trace->alert($MESSAGE)β this issues a warning at the frame (filename and line number where errors should be reported).$trace->throw($MESSAGE)β this throws an exception at the frame (filename and line number where errors should be reported).($package, $file, $line, $subname) = $trace->call()β get the caller details for the debug-info. This is where errors should be reported.$pkg = $trace->packageβ get the debug-info package.$file = $trace->fileβ get the debug-info filename.$line = $trace->lineβ get the debug-info line number.$subname = $trace->subnameβ get the debug-info subroutine name.$sig = trace->signatureβ get a signature string that identifies this trace. This is used to check if multiple events are related. The signature includespid,tid,file, line number, and thecid.
πΈ SOURCE πΈ
The source code repository for Test2 can be found at <https://github.com/Test-More/test-more/>.
π§ MAINTAINERS π§
Chad Granum <exodist@cpan.org>
β AUTHORS β
Chad Granum <exodist@cpan.org>
π COPYRIGHT π
Copyright Chad Granum <exodist@cpan.org>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See <https://dev.perl.org/licenses/>
mwah π that's the whole Test2::...::Trace(3pm) page, bestie β brought to you by perl v5.42.3, dated 2026-11-03. Go slay your debugging era β¨
π¦ where this page comes from
- alpine 3.24: perl-doc 5.42.3-r0 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms