logform
A composable, mutable object-based log format library for chaining and objectMode streams, used by the winston logger.
Repository Health
Technical Analysis
logform provides the format-composition system used by winston: each format is a small prototype object exposing a synchronous transform(info, opts) method that mutates a log-message info object and returns it (or a falsey value to filter the message out). Built-in formats cover common needs — json, colorize, timestamp, printf, simple, label, splat, errors, logstash, metadata, padLevels, prettyPrint, align, cli, and uncolorize — and any number of them can be chained together with format.combine.
Because info objects carry shared Symbol properties (LEVEL, MESSAGE, SPLAT) from the companion triple-beam package, formats produced by different libraries can interoperate safely without colliding on plain string keys. logform is a foundational dependency of the broader winston logging ecosystem, but is independently useful and independently published, seeing tens of millions of weekly downloads.
What You Get
- A
format(transformFn)factory for defining new custom formats format.combineto chain multiple formats into a single pipeline- Built-in formats: json, colorize, timestamp, printf, simple, label, splat, errors, logstash, metadata, padLevels, prettyPrint, align, cli, uncolorize
- Shared
Symbolproperties (viatriple-beam) forlevel,message, andsplatso formats interoperate without key collisions - Support for filtering out log messages entirely by returning a falsey value from a format’s transform
Common Use Cases
- Composing a custom winston logger format pipeline (e.g. timestamp + colorize + printf)
- Building application-specific log formats that add fields like request IDs or environment tags
- Filtering sensitive or private log entries before they reach a transport
- Formatting logs for downstream systems like Logstash or structured JSON log aggregators
Under The Hood
Architecture - format.js is the core factory: it validates that a given transform(info, opts) function takes at most two arguments, wraps it in a Format prototype (Format.prototype.transform = formatFn), and returns a createFormatWrap function whose .Format property exposes the class for testability — this is the pattern every built-in format (json.js, colorize.js, timestamp.js, printf.js, etc.) is built on. combine.js chains formats by iterating an array of format instances and calling each transform in sequence, stopping early if any returns a falsey info. index.js re-exports format plus every built-in format as named properties (format.json, format.combine, …), and browser.js provides a browser-safe subset. Tech Stack - Plain CommonJS JavaScript with a small, deliberate dependency set: triple-beam for shared Symbols, safe-stable-stringify for the json format, fecha for timestamp formatting, ms for the ms format, and @colors/colors for the colorize/cli formats; Babel compiles the browser build (npm run build). Code Quality - test/ contains a .test.js file per format (colorize, json, printf, combine, errors, etc.) run via Mocha with nyc coverage, and npm run pretest enforces ESLint (@dabh/eslint-config-populist) before tests run, giving each format focused, isolated test coverage. API Design - The transform(info, opts) contract is uniform across every format, so learning one format (e.g. timestamp()) transfers directly to writing a custom one via format(fn), and format.combine composes them with simple array-like chaining — the main friction for newcomers is understanding the shared-Symbol (LEVEL/MESSAGE/SPLAT) convention that lets formats interoperate.
Used by 4 apps in this directory
APITable
Low Code Platforms · Databases
API-first collaborative spreadsheet-database platform that auto-generates REST APIs and lets teams build internal tools, CRMs, and dashboards without code.
Amplication
Developer Tools · AI Code Assistants · Automation
Create production-ready backend services with your organization's standards baked in — generating NestJS, Prisma, and GraphQL code that you own and control.
Laudspeaker
Marketing · Automation
Open-source customer engagement platform for building visual, event-triggered messaging journeys across email, SMS, push, in-app, and webhooks.
n8n
Automation · No Code Platforms
Code when you need it, UI when you don't — the workflow automation platform built for technical teams who refuse to choose.