简体   繁体   English

System.out.println()消息在客户端GWT模块中调用时会在哪里发生?

[英]Where do System.out.println() messages go, when it is called in client-side GWT-module?

When I write messages to log (ie com.allen_sauer.gwt.log.client.Log#debug ) I can see them in Chrome->F12->Console or (during debug) in IDEA->Debug->Dev Mode. 当我将消息写入日志(即com.allen_sauer.gwt.log.client.Log#debug )时,我可以在Chrome-> F12-> Console中或在(在调试期间)在IDEA-> Debug-> Dev Mode中看到它们。 But if the System.out.println() was used in IDEA the messages appear in the same place as the logged ones, but what about when I am not debugging? 但是如果在IDEA中使用了System.out.println() ,则消息与记录的消息出现在同一个地方,但是当我没有调试时呢? where do they go? 他们去哪里?

System.out.println() are just removed by the compiler in production mode. System.out.println()只是在生产模式下由编译器删除。

If you want to check just create this simple module: 如果你想检查一下,只需创建这个简单的模块:

public class Foo implements EntryPoint {

  public void onModuleLoad() {

    System.out.println("Hello World!");
  }
}

And look at the generated javascript. 并查看生成的JavaScript。

The preferred way to do logging (at development time) is com.google.gwt.core.client.GWT.log() . 进行日志记录(开发时)的首选方法是com.google.gwt.core.client.GWT.log() Messages logged this way will also wind up in your browser's console like you mention. 以这种方式记录的消息也将在您提到的浏览器控制台中结束。 Likely System.out.println is mapped to the same functionality for convenience. 为方便起见,可能System.out.println映射到相同的功能。 From the GWT.log Javadoc: 来自GWT.log Javadoc:

Logs a message to the development shell logger in Development Mode, or to the console in Super Dev Mode. 在开发模式下将消息记录到开发shell记录器,或在Super Dev Mode中记录到控制台。 Calls are optimized out in Production Mode. 呼叫在生产模式下进行了优化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM