-
Couldn't load subscription status.
- Fork 16
Description
Hello WinterCG community,
I've been working on a structured logging API for Node.js (issue #49296), but discussions with @ovflowd highlighted that this should be a cross-runtime standard rather than Node.js-specific.
Problem
JavaScript runtimes lack a standard logging API. Developers either use console.log() which lacks structure and performance, rely on heavy dependencies like Winston or Pino, or build custom solutions. This fragments the ecosystem and breaks cross-runtime compatibility.
Why WinterCG
As @ovflowd noted, adding Node-specific logging would be disruptive for web codebases and mixed runtime environments. A logging API needs to work consistently across Node.js, Deno, Bun, and Cloudflare Workers without breaking web standards.
Proposal
A minimal structured logging API inspired by Go's slog:
import { createLogger, JSONHandler } from 'runtimeName:log';
const logger = createLogger({
handler: new JSONHandler({ level: 'info' })
});
logger.info({ msg: 'user login', userId: 123 });
// {"level":"info","msg":"user login","userId":123,"time":1737504000000}Core features:
Handler-based architecture for flexible output formats
Structured logging with mandatory messages
Child loggers for context inheritance
Standard log levels (trace, debug, info, warn, error, fatal)
Performance-focused design
Current Status
RFC drafted: https://hackmd.io/@yIgGSSJ6TnqZqU2oFRX-sQ/node-log
Node.js community engaged
Questions
Is this appropriate for WinterCG standardization?
What is the process for proposing new runtime APIs here?
Should this be a new proposal repo or part of proposal-minimum-common-api?
Which runtimes should be involved initially?
References
Go slog: https://go.dev/blog/slog
RFC5424: https://datatracker.ietf.org/doc/html/rfc5424
Node.js discussion: nodejs/node#49296