event static method

void event(
  1. String type, {
  2. TraceTag tag = TraceTag.general,
  3. Map<String, Object?> fields = const <String, Object?>{},
})

Writes a structured trace event payload.

The output line format is stable and machine-parseable: "[+123us] [input] @event {\"v\":1,\"type\":\"...\",...}".

Implementation

static void event(
  String type, {
  TraceTag tag = TraceTag.general,
  Map<String, Object?> fields = const <String, Object?>{},
}) {
  if (!enabled || !isTagEnabled(tag)) return;
  if (type.trim().isEmpty) return;
  final payload = <String, Object?>{
    'v': _eventSchemaVersion,
    'type': type,
    ...fields,
  };
  _writeRaw('[${tag.name}] $_eventMarker${jsonEncode(payload)}');
}