Skip to content

Commit

Permalink
Factor out trace output repeated code
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Nov 25, 2017
1 parent d3eace6 commit 67911df
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/Cro.pm6
Expand Up @@ -374,21 +374,23 @@ class Cro::PipelineTraceTransform does Cro::Transform {
supply {
whenever $in -> \msg {
my $output = (try msg.trace-output) // msg.perl;
note "[TRACE($!label)] $!component.^name() EMIT {encode $output}";
$*ERR.flush;
self!output-trace: "EMIT {encode $output}";
emit msg;
LAST {
note "[TRACE($!label)] $!component.^name() DONE";
$*ERR.flush;
self!output-trace: "DONE";
}
QUIT {
note "[TRACE($!label)] $!component.^name() QUIT {encode .gist}";
$*ERR.flush;
self!output-trace: "QUIT {encode .gist}";
}
}
}
}

method !output-trace($message --> Nil) {
note "[TRACE($!label)] $!component.^name() $message";
$*ERR.flush;
}

my $encode = ?%*ENV<CRO_TRACE_MACHINE_READABLE>;
sub encode(Str $_) {
$encode
Expand Down

0 comments on commit 67911df

Please sign in to comment.