LogTape
Zero-dependency, library-first structured logging for JavaScript and TypeScript across Deno, Node.js, Bun, browsers, and edge functions.
Repository Health
Technical Analysis
LogTape is a structured logging library for JavaScript and TypeScript built around a library-first philosophy: dependencies can log freely without forcing any configuration, sink, or logging framework onto the applications that consume them, while the application retains full control over what gets emitted and where. It ships with zero runtime dependencies and runs identically across Deno, Node.js, Bun, browsers, and edge functions, using tagged template literals for structured, typed log messages instead of printf-style format strings.
Loggers are organized into a hierarchical category tree, so verbosity and sink assignment can be tuned per subsystem without touching call sites. LogTape ships built-in sinks for console output, streams, and buffered fingers-crossed logging, pattern- and field-based data redaction, and throttling filters for noisy log lines, plus first-class integrations for Express, Fastify, Hono, Koa, GraphQL Yoga, and Drizzle ORM that auto-instrument HTTP requests, GraphQL resolution, and database queries. The surrounding monorepo adds adapters for Winston, Pino, Bunyan, and log4js, plus sinks for OpenTelemetry, Sentry, AWS CloudWatch Logs, syslog, and Windows Event Log.
What You Get
- A hierarchical category-based logger tree that lets you control verbosity and sink routing per subsystem without changing call sites.
- Zero-dependency, tagged-template-literal structured logging that works identically across Deno, Node.js, Bun, browsers, and edge functions.
- Built-in sinks for console output, streams, and buffered/fingers-crossed logging, plus pattern- and field-based data redaction and throttling filters.
- First-class framework integrations (Express, Fastify, Hono, Koa, GraphQL Yoga, Drizzle ORM) that auto-instrument requests, resolvers, and queries.
- A monorepo of adapters and sinks (Winston, Pino, Bunyan, log4js, OpenTelemetry, Sentry, CloudWatch Logs, syslog, Windows Event Log) for wiring LogTape into existing logging pipelines.
Common Use Cases
- Adding logging to a shared library or SDK without forcing consumers to adopt a specific logging framework or configuration.
- Instrumenting an Express, Fastify, Hono, or Koa API with automatic request/response logging and per-route category filtering.
- Redacting sensitive fields such as tokens, passwords, or PII from structured logs before they reach a sink, using pattern- or field-based rules.
- Shipping application logs to OpenTelemetry, Sentry, AWS CloudWatch Logs, or a syslog collector via a dedicated LogTape sink.
Under The Hood
Architecture
The core package is organized around a small set of composable modules: level.ts defines the ordered log-level scale, record.ts defines the immutable LogRecord shape, logger.ts implements the Logger interface and its LoggerImpl with hierarchical category resolution and template-literal message rendering, config.ts (backed by scoped-config.ts) exposes configure/withConfig to wire sinks and filters onto category trees either globally or for the duration of a callback, sink.ts defines the Sink contract along with built-in console/stream/fingers-crossed sinks, and context.ts layers implicit contextual properties on top of an injectable ContextLocalStorage (AsyncLocalStorage-backed on Node). Because sinks, filters, and loggers are all resolved through this same category tree, changing the core resolution logic in logger.ts or scoped-config.ts would ripple through every consumer, but the public surface stays a handful of small, independently testable functions.
Tech Stack
The package is authored in TypeScript with zero runtime dependencies, built with tsdown into dual ESM/CJS bundles plus .d.ts/.d.cts type declarations, and consumed via conditional exports/imports maps that select Node-, browser-, Deno-, or Bun-specific implementations of low-level utilities (util.node.ts, util.deno.ts). The monorepo is managed with pnpm workspaces and a shared dependency catalog, orchestrated by mise for toolchain pinning (Node, Deno, Bun, pnpm versions) and sacho/hongdown for changelog and doc-comment linting.
Code Quality
The core package carries dedicated test files alongside each module (config.test.ts, context.test.ts, filter.test.ts, formatter.test.ts, level.test.ts, logger.test.ts, sink.test.ts), combining Node’s built-in test runner with property-based testing via fast-check. CI runs the full suite across Deno, Node.js, and Bun on macOS, Ubuntu, and Windows, and a separate check task enforces deno check (strict types), deno lint, deno fmt --check, and changelog consistency before merge. Public APIs carry extensive TSDoc comments with @since/@example tags, and internal implementation details are hidden behind Symbol-keyed properties rather than exported identifiers.
API Design
The public API favors ergonomics over ceremony: libraries call getLogger(category) and log immediately with zero setup, while only the top-level application calls configure() once to decide where records actually go. Log calls use tagged template literals (logger.info`user $\{id\} logged in`) for structured, typed placeholders instead of format strings, categories are plain string arrays with prefix-based inheritance, and lazy() values let expensive contextual properties (like a request ID) stay unevaluated until a record actually passes its filters — keeping the common case a one-line call with no boilerplate.
Used by 4 apps in this directory
FastGPT
AI Agents · AI Development
Build, debug, and deploy knowledge-based AI agents with a visual workflow editor, RAG retrieval, and support for any OpenAI-compatible LLM.
likec4
Developer Tools · Devops
Define your software architecture as code and get always up-to-date, interactive C4 diagrams generated automatically from a DSL.
OpenStatus
Monitoring · Devops
Open-source status pages and uptime monitoring with global synthetic checks, monitoring-as-code, and AI agent integration via MCP.
Rudel
Developer Tools
Open-source analytics for Claude Code and Codex sessions — a CLI uploads session transcripts to a self-hostable dashboard tracking token usage, session duration, activity patterns, and model usage.