npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@dagstack/logger

v0.2.0

Published

TypeScript / Node.js binding for dagstack/logger-spec — OTel-compatible structured logging with trace/baggage propagation, scoped sink overrides, and dagstack JSON-lines wire format.

Downloads

326

Readme

@dagstack/logger

TypeScript / Node.js binding for dagstack/logger-spec — OTel-compatible structured logging with mandatory W3C Trace Context propagation, scoped sink overrides, attribute redaction, and the dagstack JSON-lines wire format.

Status: Phase 1 (v0.2.0). Implements logger-spec ADR-0001 v1.2 §1 (Log Data Model wire format), §2 (severity model), §3 (Logger API + hierarchy + context propagation), §4 (resource / instrumentation scope), §6 (scoped overrides), §7.1–§7.2 (Sink contract + Phase 1 sinks), §9 (config bootstrap), §10 (redaction including the §10.4 RedactionConfig extension surface).

Phase 2+ — OTLPSink, LokiSink, SentrySink, processor chain, runtime reconfigure, self-metrics — tracked in dagstack/logger-spec ADR §7.2.

Install

npm install @dagstack/logger @opentelemetry/api

@opentelemetry/api is a peer dependency — bring your own version (>=1.9.0 <2.0).

Quick start

import { Logger, ConsoleSink, configure } from "@dagstack/logger";

configure({
  rootLevel: "INFO",
  sinks: [new ConsoleSink({ mode: "auto" })],
  resourceAttributes: { "service.name": "my-app" },
});

const logger = Logger.get("my-app.api", "1.0.0");
logger.info("query received", { "user.id": 42 });

try {
  await doWork();
} catch (err) {
  logger.exception(err as Error, { "request.id": "req-abc" });
}

Scoped sink overrides (tests / per-run audit)

import { InMemorySink } from "@dagstack/logger";

const memory = new InMemorySink({ capacity: 100 });
await logger.scopeSinks([memory], async (scoped) => {
  scoped.info("captured only in scope");
});
// outside the callback — back to global sinks

W3C Trace Context auto-injection

When called inside an active OTel span, trace_id / span_id / trace_flags are automatically attached to every emitted record:

import { trace } from "@opentelemetry/api";

const tracer = trace.getTracer("my-app");
await tracer.startActiveSpan("query", async (span) => {
  logger.info("inside span"); // trace_id / span_id auto-injected
  span.end();
});

Baggage entries listed in the default allowed-keys list (tenant.id, request.id, user.id) are also auto-injected as attributes.

API surface

  • Logger.get(name, version?) — registry-cached named logger.
  • logger.{trace,debug,info,warn,error,fatal}(body, attrs?) — primary severity methods.
  • logger.log(severityNumber, body, attrs?) — emit at an arbitrary severity number (1-24).
  • logger.exception(err, options?) — auto-populated exception.type / exception.message / exception.stacktrace per OTel semconv.
  • logger.child(attrs) — child logger with bound attributes.
  • logger.withSinks(sinks) / appendSinks(sinks) / withoutSinks() — detached child with replaced / extra / no sinks.
  • logger.scopeSinks(sinks, callback) — Promise-friendly scope (the closest TypeScript idiom for the spec's scopeSinks context manager).
  • logger.flush(timeoutMs?) / logger.close() — lifecycle.

Re-exported types: LogRecord, InstrumentationScope, Resource, Severity, Sink, ConsoleSink, FileSink, InMemorySink, Subscription.

Local development

git clone [email protected]:dagstack/logger-typescript.git
cd logger-typescript
npm install

make test       # vitest run
make lint       # eslint .
make typecheck  # tsc --noEmit
make build      # tsc -p tsconfig.build.json

Requirements: Node.js ≥20, TypeScript ≥5.5.

Cross-binding parity

The TypeScript binding follows the same Phase 1 surface as dagstack/logger-python: the wire format (canonical JSON-lines) is byte-identical for the same LogRecord content, severity numbering / canonical text matches, and the Sink contract is preserved. Idiomatic differences are documented in the binding's ADR (forthcoming).

Licensing

Apache-2.0 (see LICENSE).

Related