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

Support custom stdout and stderr #23

Closed
atjn opened this issue Aug 19, 2022 · 5 comments
Closed

Support custom stdout and stderr #23

atjn opened this issue Aug 19, 2022 · 5 comments
Labels
bug Something isn't working
Milestone

Comments

@atjn
Copy link
Contributor

atjn commented Aug 19, 2022

I am using wasm-vips as a dependency for a CLI tool. Currently, if vips encounters a warning, it will output it directly to the console. This is pretty annoying because the CLI tool already is outputting information to the console, so now there are random fragments of vips warnings cluttered in with the rest of the information.

I would like to be able to receive the warnings in a function, where I can write my own logic for when and where the output should be logged.
If that is not possible, the next best thing would be to tell wasm-vips to never output anything.

Maybe this is already supported? But I can't seem to figure out how it works. I have already tried this, as an attempt to make it stop outputting to the CLI, but it did not work:

import newVips from "wasm-vips";
const vips = await newVips({
	print: (stdout) => {return ""},
	printErr: (stderr) => {return ""},
	preRun: module => {
		module.print = (stdout) => {return ""};
		module.printErr = (stderr) => {return ""};
	},
});
@kleisauke
Copy link
Owner

Hi @atjn,

It looks like a bug in Emscripten's NODERAWFS filesystem backend, on the web this works properly:

import Vips from 'wasm-vips';

const log = (type, text) => console.log(`${type}: ${text}`);
const vips = await Vips({
  print: (text) => log('stdout', text),
  printErr: (text) => log('stderr', text),
  preRun: (module) => {
    // Handy for debugging
    // module.ENV.VIPS_INFO = '1';
    // module.ENV.VIPS_LEAK = '1';

    // Hide warning messages
    module.ENV.VIPS_WARNING = '0';
  }
});

For now, I can recommend setting the VIPS_WARNING environment variable, as shown in the example above.

Upstream issue: emscripten-core/emscripten#17688

@kleisauke kleisauke added the bug Something isn't working label Aug 19, 2022
@atjn
Copy link
Contributor Author

atjn commented Aug 21, 2022

Thank you so much for the absolutely excellent debug work here!

@kleisauke
Copy link
Owner

Upstream PR: emscripten-core/emscripten#18163.

@kleisauke kleisauke added this to the v0.0.5 milestone Jan 5, 2023
kleisauke added a commit that referenced this issue Jan 5, 2023
@kleisauke
Copy link
Owner

I just cherry-picked that PR in the emscripten-core/emscripten@3.1.29...kleisauke:wasm-vips-3.1.29 changeset with commit kleisauke/emscripten@cf6cdde.

This will be in v0.0.5.

@kleisauke
Copy link
Owner

v0.0.5 now available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants