Skip to content

Commit be10bab

Browse files
committed
feat: stdout improvements
1 parent 51c1dee commit be10bab

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/Span/Exporter/Stdout.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
use Utopia\Span\Span;
66

77
/**
8-
* Exports spans to stdout as JSON
8+
* Exports spans as newline-delimited JSON (NDJSON)
9+
*
10+
* Spans with errors are written to stderr, all others to stdout.
911
*/
1012
class Stdout implements Exporter
1113
{
@@ -17,6 +19,8 @@ public function export(Span $span): void
1719
return;
1820
}
1921

20-
fwrite(STDOUT, $output . PHP_EOL);
22+
$stream = $span->get('error.type') !== null ? STDERR : STDOUT;
23+
24+
fwrite($stream, $output . PHP_EOL);
2125
}
2226
}

0 commit comments

Comments
 (0)