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

What does console: 'redirect' mean #54

Closed
seanc opened this issue Feb 4, 2017 · 3 comments
Closed

What does console: 'redirect' mean #54

seanc opened this issue Feb 4, 2017 · 3 comments

Comments

@seanc
Copy link

seanc commented Feb 4, 2017

I wanted to know what you mean by "redirect to events" when using the redirect option for console in NodeVM. I have always used the sandbox method, of just attaching a console object with its own methods, however I wanted to know if there was an alternative cleaner solution

@patriksimek
Copy link
Owner

It's working like this:

const vm = new NodeVM({
    console: 'redirect'
});

vm.on('console.log', (msg) => {
	console.log('REDIRECTED:', msg);
})

vm.run("console.log('hello');");

You can listen for those events:

  • console.log
  • console.info
  • console.warn
  • console.error
  • console.dir
  • console.trace

@seanc
Copy link
Author

seanc commented Feb 8, 2017

Awesome thanks!

@phyng
Copy link

phyng commented Jun 15, 2019

Thanks! maybe we can add this to README or other documentation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants