agentcrumbs

Sinks

Configure where crumbs are sent

By default, crumbs are sent via HTTP to the collector and also printed to the console. In Node.js, output goes to stderr with ANSI colors. In the browser, output goes to console.debug() with CSS styling. You can add custom sinks or replace the defaults.

Custom sink

import { trail, addSink, removeSink } from "agentcrumbs";
import type { Sink, Crumb } from "agentcrumbs";

const mySink: Sink = {
  write(crumb: Crumb) {
    myLogger.info(crumb);
  },
};

addSink(mySink);

Built-in sinks

HttpSink

Sends crumbs to the collector via HTTP. Added automatically when AGENTCRUMBS is set.

import { HttpSink } from "agentcrumbs";

ConsoleSink

Pretty-printed console output. Added automatically when tracing is enabled.

  • Node.js: ANSI-colored output to stderr
  • Browser: CSS-styled output via console.debug(), with console.groupCollapsed() for scopes and interactive object rendering in DevTools
import { ConsoleSink } from "agentcrumbs";

Sink interface

interface Sink {
  write(crumb: Crumb): void;
}

The write method receives a Crumb object (see crumb format). It should not throw.

On this page