triple-beam

Shareable Symbol constants and standard logging-level configs for the winston ecosystem

Library
npm
v1.4.1
26stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
27/100Needs Attention
Development Activity0
Maintenance20
Community16
Maturity60
Momentum12

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
55/100Fair
Architecture45
Code Quality60
Innovation35
Learning Curve80

triple-beam is a tiny utility package used internally by winston and logform to share a small set of well-known JavaScript Symbols — LEVEL, MESSAGE, and SPLAT — across otherwise independent packages without risking collisions with user-defined object properties. Because they’re Symbols rather than string keys, logging metadata can travel alongside a log entry (e.g. the raw, uncolorized level) without being visible to JSON.stringify or enumerable property iteration.

Alongside the symbols, it ships standard level/color definitions (npm, syslog, cli) so logging libraries that want npm-style or syslog-style severity levels don’t need to redefine them from scratch.

What You Get

  • LEVEL, MESSAGE, and SPLAT exported Symbol constants for attaching hidden/non-enumerable metadata to log info objects
  • configs.npm — the standard npm-style levels (error, warn, info, http, verbose, debug, silly) with matching terminal colors
  • configs.syslog — RFC 5424-style syslog levels (emerg through debug) with matching colors
  • configs.cli — a CLI-oriented level/color set used by winston’s CLI format

Common Use Cases

  • Building a winston-compatible log formatter that needs to read the raw level via the shared LEVEL symbol without mutating the user-visible level string
  • Implementing a custom logform transform that needs access to the original interpolation arguments via the SPLAT symbol
  • Bootstrapping a new logging library with battle-tested npm or syslog level/color defaults instead of hand-rolling them
  • Interoperating with the winston ecosystem by attaching metadata in a way third-party formatters already know how to read

Under The Hood

Architecture - The entire package is a single index.js (about 40 lines) that uses Object.defineProperty to attach three well-known Symbols (LEVEL, MESSAGE, SPLAT, each created via Symbol.for(...) so they’re globally registered and shared across separately-installed copies of the package) plus a configs object onto exports. The configs object is populated from config/index.js, which re-exports four small files (npm.js, syslog.js, cli.js, and a shared allColors merge) each defining a flat levels map (level name → numeric severity) and a matching colors map (level name → terminal color name). Tech Stack - Plain CommonJS, zero runtime dependencies; devDependencies are limited to mocha/nyc/assume for testing and @dabh/eslint-config-populist for linting, plus a typescript devDependency used only to validate the shipped .d.ts types. Code Quality - test.js is a small mocha/assume suite asserting each symbol is defined and that the configs object structurally matches what winston expects; JSDoc comments annotate every export in index.js, and the config files are similarly documented with copyright/license headers per file. There are no complex code paths to test — the package is essentially static data plus symbol definitions. API Design - The public surface is intentionally tiny: three symbols and one nested config object, all consumed via simple destructuring (const { LEVEL, MESSAGE, SPLAT } = require('triple-beam')), which makes onboarding instant for anyone already using winston; the tradeoff is that the package is meaningless standalone — it only makes sense in the context of the winston/logform ecosystem it was extracted from.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search