Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add info and debug logging to console global #68

Merged
merged 1 commit into from
Apr 25, 2024

Conversation

Phault
Copy link
Contributor

@Phault Phault commented Apr 21, 2024

Noticed console.debug was missing, so figured I'd add it. It's also not obvious what log level console.log has, so I added console.info as well as an alias, which seems to match browser behaviour.

Diff looks a bit confusing, as I sorted the functions based on log level. 🤷

@nilslice nilslice requested a review from bhelx April 23, 2024 04:20
@nilslice
Copy link
Member

nilslice commented Apr 23, 2024

Thanks, @Phault!

While we're in here, I wonder if it would be a good time to consider how we could support variadic args for the console functions.

For example, in JS, console.log takes any number of args and logs them, e.g.:

console.log("this", "is", "a", variable, 42, {a: 1}, [1, 2, variable, 3])

We only support using the first arg.

How close can we get these functions?

cc/ @bhelx

@bhelx
Copy link
Contributor

bhelx commented Apr 25, 2024

Thanks for contributing! Let's merge this as is. I think it's a welcome addition. I'll create an issue for making these compatible with the w3c console.log, etc. I do think it might be easier to, instead of implementing some of these globals like console in rust, just expose the IO primitives from rust and implement it in JS in the polyfill layer. Open to different ideas on how to do it though.

@bhelx bhelx merged commit 2d72d29 into extism:main Apr 25, 2024
2 checks passed
@Phault Phault deleted the log-levels branch April 29, 2024 16:10
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.

3 participants