-
public final class TracerAn append-only, thread-safe trace buffer that can be snapshotted and rolled back.
All state mutations are guarded by lock, ensuring atomicity across threads.
-
-
Method Summary
Modifier and Type Method Description final BooleanisEnabled()Returns true if tracing is enabled, false otherwise. final <ERROR CLASS>setEnabled(Boolean enabled)Enables or disables tracing. final Unittrace(String tag, Object data)Records a trace entry when tracing is enabled. final TraceSlicetake()Returns a snapshot of the current buffer and clears it. final <ERROR CLASS>dispose()Permanently discards all buffered trace entries. -
-
Constructor Detail
-
Tracer
Tracer(String id)
-
-
Method Detail
-
setEnabled
final <ERROR CLASS> setEnabled(Boolean enabled)
Enables or disables tracing.
Switching state clears any existing buffered entries.
-
trace
final Unit trace(String tag, Object data)
Records a trace entry when tracing is enabled.
The lambda form matches the original TypeScript API and can be stored or passed around as a function reference.
-
take
final TraceSlice take()
Returns a snapshot of the current buffer and clears it.
The returned TraceSlice.rollback reinserts the snapshot at the front of the buffer, preserving original ordering.
-
dispose
final <ERROR CLASS> dispose()
Permanently discards all buffered trace entries.
-
-
-
-