Skip to content

Proposal: Cross-Runtime Structured Logging API #107

@mertcanaltin

Description

@mertcanaltin

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions