The fastest, lightest, and most extensible logger for JavaScript
82% smaller than Pino β’ Zero dependencies β’ Universal runtime support
import { createLogger } from '@sylphx/cat'
const logger = createLogger()
logger.info('Hello from cat! π±')| Feature | @sylphx/cat | Pino | Winston |
|---|---|---|---|
| Core Size | 1.97 KB | 11 KB | 28 KB |
| Full Stack | 11 KB | ~20 KB | ~35 KB |
| Zero Dependencies | β | β | β |
| TypeScript Native | β | β | β |
| W3C Trace Context | β | β | β |
| OTLP Export | β | Plugin | β |
| Tail Sampling | β | β | β |
| OWASP 2024 Compliant | β | β | β |
Cat is a modular monorepo - install only what you need:
| Package | Size | Description |
|---|---|---|
| @sylphx/cat | 1.97 KB | Core logger + JSON + Console + Error serialization |
| @sylphx/cat-pretty | 0.81 KB | Pretty formatter for development |
| @sylphx/cat-file | 1.14 KB | File and stream transports |
| @sylphx/cat-http | 0.75 KB | HTTP request/response serializers |
| @sylphx/cat-otlp | 1.64 KB | OpenTelemetry Protocol export |
| @sylphx/cat-tracing | 1.46 KB | W3C Trace Context support |
| @sylphx/cat-redaction | 1.49 KB | PII/sensitive data redaction |
| @sylphx/cat-tail-sampling | 1.82 KB | Intelligent cost-saving sampling |
Total: 11.08 KB for the complete observability stack
npm install @sylphx/catimport { createLogger } from '@sylphx/cat'
const logger = createLogger()
logger.info('Server started', { port: 3000 })
// {"level":"info","msg":"Server started","port":3000,"time":1700000000000}
logger.error(new Error('Connection failed'))
// {"level":"error","err":{"message":"Connection failed","stack":"..."},"time":...}npm install @sylphx/cat @sylphx/cat-prettyimport { createLogger } from '@sylphx/cat'
import { prettyFormatter } from '@sylphx/cat-pretty'
const logger = createLogger({
formatter: prettyFormatter()
})
logger.info('Hello world')
// [2024-11-14 20:30:15] INF Hello worldnpm install @sylphx/cat @sylphx/cat-file @sylphx/cat-httpimport { createLogger } from '@sylphx/cat'
import { fileTransport } from '@sylphx/cat-file'
import { httpSerializers } from '@sylphx/cat-http'
const logger = createLogger({
serializers: httpSerializers,
transports: [fileTransport({ path: './logs/app.log' })]
})
// Express middleware
app.use((req, res, next) => {
logger.info({ req }, 'Incoming request')
next()
})npm install @sylphx/cat @sylphx/cat-otlp @sylphx/cat-tracing \
@sylphx/cat-tail-sampling @sylphx/cat-redactionimport { createLogger } from '@sylphx/cat'
import { otlpTransport } from '@sylphx/cat-otlp'
import { tracingPlugin } from '@sylphx/cat-tracing'
import { tailSamplingPlugin } from '@sylphx/cat-tail-sampling'
import { redactionPlugin } from '@sylphx/cat-redaction'
const logger = createLogger({
plugins: [
tracingPlugin(),
redactionPlugin({ pii: true }),
tailSamplingPlugin({ monthlyBudget: 100_000 })
],
transports: [
otlpTransport({
endpoint: 'https://api.honeycomb.io/v1/logs',
headers: { 'x-honeycomb-team': process.env.API_KEY }
})
]
})
logger.info({ userId: 123, event: 'purchase' })
// Automatically:
// - Adds traceId for distributed tracing
// - Redacts PII (credit cards, SSNs, emails)
// - Samples intelligently (100% errors, 10% success)
// - Exports to Honeycomb via OTLP- β‘ Ultra-fast: Optimized hot paths, minimal allocations
- πͺΆ Ultra-lightweight: 1.97 KB gzipped core
- π§ Type-safe: Full TypeScript support with strict types
- π Universal: Works in Bun, Node.js, Deno, browsers
- π― Zero dependencies: No external runtime dependencies
- π¦ Tree-shakeable: Pay only for what you use
- π Extensible: Plugin system for custom behavior
- π¨ Customizable: Formatters, transports, serializers
β οΈ Auto error serialization: Errors serialized with stack traces
-
π W3C Trace Context (@sylphx/cat-tracing)
- Full W3C Trace Context specification
- Distributed tracing across microservices
- Parent-child span relationships
-
π OTLP Export (@sylphx/cat-otlp)
- OpenTelemetry Protocol (OTLP) HTTP/JSON
- Compatible with Grafana, Datadog, New Relic, Honeycomb
- Batching with exponential backoff retry
-
π OWASP 2024 Compliant Redaction (@sylphx/cat-redaction)
- Field-based redaction with glob patterns
- Built-in PII detection (credit cards, SSNs, emails, phones)
- Log injection prevention
-
π° Tail-Based Sampling (@sylphx/cat-tail-sampling)
- Smart sampling after trace completion
- 40-90% cost reduction
- 100% error coverage
- Adaptive budget control
-
π HTTP Serializers (@sylphx/cat-http)
- Automatic Request/Response serialization
- Sensitive header redaction
- Express/Fastify compatible
Core logger performance:
@sylphx/cat: 25M ops/sec
Pino: 20M ops/sec
Winston: 12M ops/sec
Bundle size comparison:
Core only:
@sylphx/cat: 1.97 KB (82% smaller)
Pino: 11 KB
Winston: 28 KB
Full stack:
@sylphx/cat: 11 KB
Pino + plugins: ~20 KB
Winston + plugins: ~35 KB
npm install @sylphx/cat1.97 KB - Just the essentials
npm install @sylphx/cat @sylphx/cat-pretty2.78 KB - Beautiful colored output
npm install @sylphx/cat @sylphx/cat-file @sylphx/cat-http3.86 KB - File logging + HTTP serialization
npm install @sylphx/cat @sylphx/cat-otlp @sylphx/cat-tracing5.07 KB - Distributed tracing + OTLP export
npm install @sylphx/cat @sylphx/cat-otlp @sylphx/cat-tracing \
@sylphx/cat-tail-sampling @sylphx/cat-redaction9.08 KB - Full observability with cost optimization
const logger = createLogger({ service: 'api' })
const requestLogger = logger.child({ requestId: '123' })
requestLogger.info('Processing')
// {"service":"api","requestId":"123","level":"info","msg":"Processing"}import { createLogger } from '@sylphx/cat'
const logger = createLogger({
serializers: {
user: (user) => ({ id: user.id, name: user.name })
}
})
logger.info({ user: { id: 1, name: 'Alice', password: 'secret' } })
// {"level":"info","user":{"id":1,"name":"Alice"}}import { createLogger } from '@sylphx/cat'
import { fileTransport } from '@sylphx/cat-file'
import { otlpTransport } from '@sylphx/cat-otlp'
const logger = createLogger({
transports: [
fileTransport({ path: './logs/app.log' }),
otlpTransport({ endpoint: 'https://...' })
]
})import type { Plugin, LogEntry } from '@sylphx/cat'
const timestampPlugin: Plugin = {
name: 'timestamp',
onLog: (entry: LogEntry) => {
entry.timestamp = new Date().toISOString()
return entry
}
}
const logger = createLogger({
plugins: [timestampPlugin]
})- β Bun 1.0+
- β Node.js 18+
- β Deno 1.37+
- β Browsers (modern)
- β Edge runtimes (Cloudflare Workers, Vercel Edge)
- β OpenTelemetry OTLP 1.0+
- β W3C Trace Context Specification
- β OWASP Top 10 2024
Cat has comprehensive test coverage with 330 tests across all packages:
# Run all tests (330 tests)
bun test
# Run specific package tests
cd packages/cat && bun test # Core (82 tests)
cd packages/cat-http && bun test # HTTP serializers (52 tests)
cd packages/cat-tracing && bun test # W3C Trace Context (66 tests)
cd packages/cat-redaction && bun test # PII redaction (33 tests)
cd packages/cat-tail-sampling && bun test # Tail sampling (26 tests)
cd packages/cat-otlp && bun test # OTLP transport (26 tests)Test Coverage: 95%+ (See detailed report)
- β All log levels and filtering
- β Formatters (JSON, Pretty)
- β Transports (Console, File)
- β Error serialization with cause chains
- β Plugin lifecycle (onInit, onLog, onDestroy)
- β HTTP serialization with security
- β Distributed tracing (W3C standard)
- β PII protection (OWASP 2024 compliant)
- β Intelligent sampling
- β Real-world integration scenarios
We welcome contributions! Please see CONTRIBUTING.md for details.
# Clone the repo
git clone https://github.com/SylphxAI/cat.git
cd cat
# Install dependencies
bun install
# Build all packages
bun run build
# Run tests (330 tests, 95%+ coverage)
bun testMIT Β© Kyle Zhu
Inspired by:
- Pino - Fast JSON logger
- Winston - Versatile logging library
- OpenTelemetry - Observability standards
Built with β€οΈ by the SylphX team