Skip to content

Adapter packages for popular logging libraries #52

Description

@dahlia

Summary

Create adapter packages to integrate LogTape with existing logging ecosystems. This would allow applications that already use established logging libraries (winston, pino, etc.) to easily incorporate LogTape-enabled libraries without requiring a full migration.

Motivation

LogTape's library-friendly design is one of its key strengths—it's unobtrusive, has zero dependencies, and is tree-shakable. However, this creates a practical adoption barrier:

  1. Library awesome-pkg uses LogTape for logging
  2. Application already uses winston/pino/log4js in production
  3. Migrating the entire logging system just for one library is often impractical

This prevents LogTape-enabled libraries from being adopted in applications with existing logging infrastructure.

Proposed Solution

Develop adapter packages that bridge LogTape with popular logging libraries:

  • @logtape/adapter-winston
  • @logtape/adapter-pino
  • @logtape/adapter-log4js
  • @logtape/adapter-bunyan

Usage Examples

Explicit configuration:

import { configure } from "@logtape/logtape";
import { getWinstonSink } from "@logtape/adapter-winston";

await configure({
  sinks: {
    winston: getWinstonSink(), // Use default winston instance
    // or: getWinstonSink(existingWinstonLogger)
  },
  loggers: [
    { category: "awesome-pkg", sinks: ["winston"] }
  ]
});

Auto-configuration facade (optional):

// Automatically routes all LogTape logs to winston
import "@logtape/adapter-winston/install";

This would route all LogTape logs to the application's existing winston logging system with minimal setup.

Benefits

  • Seamless integration: Applications can use LogTape-enabled libraries without changing their logging infrastructure
  • Gradual adoption: Specific libraries can be configured individually
  • Ecosystem growth: Expands LogTape's reach while maintaining its core design principles

Implementation Considerations

  • Map LogTape log levels to target library equivalents
  • Handle structured logging and context appropriately
  • Maintain performance characteristics

Priority

Start with the most widely used logging libraries:

  1. winston (most popular)
  2. pino (high performance, structured logging)
  3. Implement log4js adapter package (@logtape/adapter-log4js) #57
  4. Implement Bunyan adapter package (@logtape/adaptor-bunyan) #58

This enhancement would significantly lower the barrier to adopting LogTape-enabled libraries in existing applications.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions