Skip to content

Add structured logging example using event callbacks #4

@TheCryptoDonkey

Description

@TheCryptoDonkey

toll-booth emits onRequest, onChallenge, and onPayment callbacks that give operators visibility into the payment flow. There is no example showing how to wire these into a structured logging setup (JSON lines, pino, etc.). A working example would help operators monitor their deployments in production.

Scope

  • Create examples/structured-logging/ with a minimal Express server
  • Wire onRequest, onChallenge, and onPayment callbacks to produce JSON log lines to stdout
  • Include fields like timestamp, client IP, route, amount, payment hash, and credit balance
  • Add a README.md explaining the callback signatures and when each fires

Helpful context

  • src/types.ts lines 347-349 - the three event callback signatures (onPayment, onRequest, onChallenge)
  • src/stats.ts - the built-in StatsCollector that uses these same callbacks internally
  • src/booth.ts lines 128-132 - how the Booth constructor wires user callbacks alongside stats collection
  • Estimated effort: 1-2 hours

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationgood first issueGood for newcomers

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions