Skip to content

Comments

PS-9195: JS Stored Routines: console log support#5571

Merged
dlenev merged 1 commit intopercona:js-langfrom
dlenev:js-lang-9195
Mar 27, 2025
Merged

PS-9195: JS Stored Routines: console log support#5571
dlenev merged 1 commit intopercona:js-langfrom
dlenev:js-lang-9195

Conversation

@dlenev
Copy link
Contributor

@dlenev dlenev commented Mar 21, 2025

https://perconadev.atlassian.net/browse/PS-9192

Added support for JS Console Log to our implementation of JS Stored Programs.

Users can now use console.log() and other calls described in the JS Console Standard in their JS Stored Programs to log messages to debugging console. And then access to buffered output of the console through UDFs.

The main purpose of this tool is to simplify debugging and profiling of JS routines.

A few things to note:

  • Most of calls described in JS Console Standard are supported.
  • Each connection and user pair gets its own Console instance (similarly to JS Contexts).
  • While JS_GET_CONSOLE_LOG() UDF provides access to simple, plain version of console output (similar to Node.JS), JS_GET_CONSOLE_LOG_JSON() provides access to extended, more structured version of console log in JSON form.
  • We also support clearing the console log from SQL session through JS_CLEAR_CONSOLE_LOG() UDF.

Added test coverage for this functionality.

@dlenev dlenev requested a review from percona-ysorokin March 21, 2025 17:54
Copy link
Collaborator

@percona-ysorokin percona-ysorokin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

https://perconadev.atlassian.net/browse/PS-9195

Added support for JS Console Log to our implementation of
JS Stored Programs.

Users can now use console.log() and other calls described in
the JS Console Standard in their JS Stored Programs to log
messages to debugging console. And then access to buffered
output of the console through UDFs.

The main purpose of this tool is to simplify debugging and
profiling of JS routines.

A few things to note:
- Most of calls described in JS Console Standard are supported.
- Each connection and user pair gets its own Console instance
  (similarly to JS Contexts).
- While JS_GET_CONSOLE_LOG() UDF provides access to simple, plain
  version of console output (similar to Node.JS),
  JS_GET_CONSOLE_LOG_JSON() provides access to extended, more
  structured version of console log in JSON form.
- We also support clearing the console log from SQL session
  through JS_CLEAR_CONSOLE_LOG() UDF.

Added test coverage for this functionality.
@dlenev dlenev merged commit f939520 into percona:js-lang Mar 27, 2025
19 of 22 checks passed
@dlenev dlenev deleted the js-lang-9195 branch March 27, 2025 09:42
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