Introduction

Vestig is a lightweight, zero-dependency structured logging library designed for modern JavaScript runtimes.

Leave a trace.

Why Vestig?

Most logging libraries are either too simple (just console.log wrappers) or too complex (requiring extensive configuration). Vestig strikes the perfect balance:

  • Zero dependencies — No external packages, minimal bundle size
  • Universal runtime support — Node.js, Bun, Deno, Edge, and Browser
  • First-class Next.js support — Dedicated @vestig/next package with full App Router support
  • Production-ready — Structured JSON output, log levels, and timestamps
  • Security-first — Automatic PII sanitization with GDPR, HIPAA, and PCI-DSS presets
  • Native tracing — Built-in span support with W3C Trace Context compatibility
  • Smart sampling — Probability, rate-limit, and namespace-based sampling

Features at a Glance

FeatureDescription
Structured LoggingJSON output with timestamps, levels, metadata, and context
PII SanitizationAuto-redact passwords, emails, tokens, credit cards with compliance presets
Tracing & SpansNative span support for tracking operations and their relationships
Context PropagationRequest tracing with correlation IDs via AsyncLocalStorage
Multiple TransportsConsole, HTTP, File, and Datadog transports out of the box
SamplingControl log volume with probability, rate-limit, or namespace-based sampling
Child LoggersNamespaced loggers with inherited configuration
Multi-RuntimeNode.js, Bun, Deno, Edge, and Browser support
TypeScriptFull type safety and inference

Packages

PackageDescription
vestigCore logging library with all features
@vestig/nextFirst-class Next.js 15+ integration
@vestig/expressExpress.js middleware and utilities

Quick Example

typescript
import { log } from 'vestig'

// Simple logging
log.info('User signed up', { userId: 'usr_123' })

// With PII sanitization (automatic)
log.info('User data', {
  email: 'user@example.com',  // → partially masked
  password: 'secret123',       // → [REDACTED]
  cardNumber: '4111...'        // → [CARD REDACTED]
})

// With tracing
import { span } from 'vestig'

await span('api:request', async (s) => {
  s.setAttribute('method', 'GET')

  await span('db:query', async () => {
    return await db.query('SELECT * FROM users')
  })
})

Next.js Example

typescript
// app/page.tsx
import { getLogger } from '@vestig/next'

export default async function Page() {
  const log = await getLogger('home')

  log.info('Rendering home page')

  return <h1>Welcome</h1>
}

Next Steps