we (web engine): Experimental web browser project to understand the limits of Claude

Console API: console.log, console.error, console.warn #106

open opened by pierrelf.com

Implement the Console API as built-in JS globals.

Scope#

Console Object#

  • Register console as a global object in the JS VM during init_builtins()
  • Implement as a plain object with native function methods

Methods#

  • console.log(...args) — format arguments and write to stdout
  • console.error(...args) — format arguments and write to stderr
  • console.warn(...args) — format arguments and write to stderr
  • console.info(...args) — alias for console.log
  • console.debug(...args) — alias for console.log (or no-op)

Formatting#

  • Convert each argument to its string representation using the existing to_js_string() on Value
  • Separate multiple arguments with spaces
  • Objects should show [object Object] or a more useful representation
  • Arrays should show their contents

Output Channel#

  • Provide a configurable output sink (trait or callback) so the browser can redirect console output to a dev tools panel later
  • Default implementation writes to stdout/stderr

Integration#

  • Works in the existing evaluate() / evaluate_with_preamble() API
  • No DOM dependency required — pure JS engine feature

Acceptance Criteria#

  • console.log("hello") prints to stdout
  • console.error("oops") prints to stderr
  • Multiple arguments: console.log("a", 1, true)a 1 true
  • Object formatting: console.log({x: 1}) → reasonable output
  • console.log does not throw — always returns undefined
  • Works with the existing Test262 infrastructure (can be used as print() replacement)

Phase 11 — DOM-JS Bindings (issue 1 of 8). No dependencies on other Phase 11 issues.

sign up or login to add to the discussion
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:meotu43t6usg4qdwzenk4s2t/sh.tangled.repo.issue/3mhyflupav42i