emit static method
Print header (already carrying prefix) and, when includeBody is on,
body on the following line — split into tagged chunks when it exceeds
chunkBytes. Routed through debugPrint so a large body is throttled
instead of dropped by rate-limited loggers.
Implementation
static void emit(String header, {String? body}) {
if (!enabled || kReleaseMode) return;
if (body == null || !includeBody) {
debugPrint(header);
return;
}
final chunks = chunk(body, chunkBytes);
if (chunks.length == 1) {
debugPrint('$header\n$body');
return;
}
final id = ++_bodySeq;
debugPrint('$header body#$id chunks=${chunks.length}');
for (var i = 0; i < chunks.length; i++) {
debugPrint('$prefix body#$id ${i + 1}/${chunks.length}] ${chunks[i]}');
}
}