logtape

Implements structured logging with LogTape across JavaScript and TypeScript runtimes.

2.0k|56|Updated Apr 16, 2024
One-click install
npx skills add https://github.com/dahlia/logtape --skill logtape
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: logtape
Source: https://github.com/dahlia/logtape/tree/main/packages/logtape/skills/logtape
Command: npx skills add https://github.com/dahlia/logtape --skill logtape

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Adding logging to JavaScript and TypeScript projects often leads to unstructured console output, misconfigured loggers, and libraries that hijack application logging configuration. This Skill guides correct usage of LogTape, a zero-dependency logging library, so logs are structured, filterable, and safe across Deno, Node.js, Bun, browsers, and edge functions.

Core Features & Use Cases

  • Structured Logging: Write log messages with named placeholders and properties objects so log data stays parseable and searchable.
  • Configuration Guidance: Set up sinks, formatters, hierarchical categories, and log levels correctly with configure() or configureSync(), including framework-specific patterns for React, Vue, Next.js, and SvelteKit.
  • Library Author Rules: Ensure library code only calls getLogger() and never configures sinks, keeping control with the application.
  • Use Case: Imagine you are adding request tracing to an Express API. The Skill shows how to create hierarchical loggers, attach request-scoped context with logger.with(), redact sensitive fields, and route errors to a filtered sink.

Quick Start

Ask the assistant to add LogTape logging to your project with a console sink, hierarchical categories, and structured messages.

Frequently Asked Questions about logtape

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I configure LogTape in a TypeScript application?

Call await configure() exactly once at startup with sinks and loggers defined, for example a console sink and a category with a lowestLevel. Use configureSync() when you cannot await, but never mix async and sync configure and reset pairs.

How do I write structured log messages with LogTape?

Use named placeholders with a properties object, such as logger.info("User {userId} logged in", { userId }). Template literals and string concatenation work for quick debugging but do not produce structured, searchable data.

Can libraries use LogTape without configuring it?

Yes, and they must. Library code should only call getLogger() and emit log messages; the consuming application decides whether and how to configure sinks and levels. Calling configure() in library code is an anti-pattern.

Does LogTape work with existing loggers like winston or Pino?

Yes, adaptor packages route LogTape output through existing loggers. Install @logtape/adaptor-winston, @logtape/adaptor-pino, or @logtape/adaptor-log4js and call install() with your existing logger instance instead of calling configure().

How do I prevent passwords and tokens from appearing in logs?

Use the @logtape/redaction package. Wrap a formatter with redactByPattern() to catch emails, JWTs, or credit card numbers in output text, or wrap a sink with redactByField() to strip sensitive properties by field name.

Why does calling configure() twice throw an error?

LogTape allows only one configuration per process and throws ConfigError on a second call. Call await reset() (or resetSync() for sync configuration) in test teardown so each test can configure independently.