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

Capturing System.out etc. in Java code called by JS #457

Open
lukehutch opened this issue Feb 4, 2025 · 6 comments
Open

Capturing System.out etc. in Java code called by JS #457

lukehutch opened this issue Feb 4, 2025 · 6 comments

Comments

@lukehutch
Copy link

Currently when JS calls Java code, System.out/System.err is not redirected to v8's console.log/console.error, so console interceptors cannot capture anything output by the embedded Java code.

Is there a way to set this up? If not, please consider this a feature request.

@AsyncProxy
Copy link

目前,当 JS 调用 Java 代码时,/ 不会重定向到 v8 的 /,因此控制台拦截器无法捕获嵌入式 Java 代码输出的任何内容。System.out``System.err``console.log``console.error

有没有办法进行设置?如果没有,请将此视为功能请求。

You can try rewriting System.out into the JS console.

@lukehutch
Copy link
Author

But how?

@AsyncProxy
Copy link

但是怎么做呢?

Javet provides a module binder annotation V8Function, which you can use to override the methods in the console and bind them to Java's System.

@AsyncProxy
Copy link

但是怎么做呢?

https://www.caoccao.com/Javet/reference/v8_values/v8_function.html Look.

@caoccao
Copy link
Owner

caoccao commented Feb 5, 2025

Please check the tutorial out.

@AsyncProxy
Copy link

Please check the tutorial out.

Can you take a look at me by the way?#456

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

No branches or pull requests

3 participants