Skip to content

Add console.log debugging statements#21

Draft
r33drichards wants to merge 2 commits intomainfrom
claude/add-console-logging-011CUswR5h8kffKZrRJCpGYN
Draft

Add console.log debugging statements#21
r33drichards wants to merge 2 commits intomainfrom
claude/add-console-logging-011CUswR5h8kffKZrRJCpGYN

Conversation

@r33drichards
Copy link
Owner

Implement console.log functionality for both stateless and stateful JavaScript execution modes. This allows JavaScript code running in the V8 isolate to output logs to stdout.

Changes:

  • Add console_log callback function to handle console.log calls
  • Add create_global_template function to set up global context with console object
  • Update execute_stateless to use custom global template with console support
  • Update execute_stateful to use custom global template with console support

The console.log implementation accepts multiple arguments and prints them space-separated to stdout, matching standard console.log behavior.

Implement console.log functionality for both stateless and stateful
JavaScript execution modes. This allows JavaScript code running in the
V8 isolate to output logs to stdout.

Changes:
- Add console_log callback function to handle console.log calls
- Add create_global_template function to set up global context with console object
- Update execute_stateless to use custom global template with console support
- Update execute_stateful to use custom global template with console support

The console.log implementation accepts multiple arguments and prints them
space-separated to stdout, matching standard console.log behavior.
Modified console.log implementation to capture output and return it
as part of the execution result instead of printing to stdout.

Changes:
- Add thread-local storage (CONSOLE_LOGS) to collect console.log output
- Update console_log callback to append to thread-local storage
- Update execute_stateless to clear logs before execution and combine with result
- Update execute_stateful to clear logs before execution and combine with result

Console logs are now included in the output, with each log on a new line,
followed by the final expression result.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants