We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
ConsoleStdout
I find ConsoleStdout from an existing test very useful to incrementally get log output while running WASI programs that use stdout/stderr:
stdout
stderr
browser_wasi_shim/test/adapters/browser/run-test.html
Lines 4 to 33 in b18b2da
In particular, in conjunction with an additional static method
static lineBuffered(write) { const dec = new TextDecoder("utf-8", { fatal: false }); let line_buf = ""; return new ConsoleStdout((buffer) => { line_buf += dec.decode(buffer, { stream: true }); const lines = line_buf.split("\n"); for (const [i, line] of lines.entries()) { if (i < lines.length - 1) { write(line); } else { line_buf = line; } } }); }
which can eg be used like this
[ new OpenFile(new File([])), // stdin ConsoleStdout.lineBuffered(msg => console.log(`[WASI stdout] ${msg}`)), ConsoleStdout.lineBuffered(msg => console.warn(`[WASI stderr] ${msg}`)), ]
Is it in scope to add this to the library such that it can be reused by other projects? If so, happy to create a PR.
The text was updated successfully, but these errors were encountered:
Yeah, seems useful to have.
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
I find
ConsoleStdout
from an existing test very useful to incrementally get log output while running WASI programs that usestdout
/stderr
:browser_wasi_shim/test/adapters/browser/run-test.html
Lines 4 to 33 in b18b2da
In particular, in conjunction with an additional static method
which can eg be used like this
Is it in scope to add this to the library such that it can be reused by other projects? If so, happy to create a PR.
The text was updated successfully, but these errors were encountered: