build method
Builds this span into another span, or returns itself if already terminal.
Override this for composable spans that build to other spans.
Default implementation returns this.
Example:
class Timestamp extends LeafSpan {
final DateTime date;
Timestamp(this.date);
@override
LogSpan build() => PlainText('${date.hour}:${date.minute}');
}
Implementation
@override
LogSpan build() {
final text = stackTrace.toString();
// Trim trailing newline to avoid extra blank line in output
if (text.endsWith('\n')) {
return PlainText(text.substring(0, text.length - 1));
}
return PlainText(text);
}