Where do System.out.println() messages go, when it is called in client-side GWT-module?
Asked Answered
A

2

5

When I write messages to log (i.e. com.allen_sauer.gwt.log.client.Log#debug) I can see them in Chrome->F12->Console or (during debug) in 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? where do they go?

Anthropomorphic answered 4/2, 2015 at 13:37 Comment(0)
S
5

System.out.println() are just removed by the compiler in production mode.

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.

Spiracle answered 4/2, 2015 at 14:6 Comment(1)
What about in Super Dev Mode? What happens to them then?Dorladorlisa
S
2

The preferred way to do logging (at development time) is 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. From the GWT.log Javadoc:

Logs a message to the development shell logger in Development Mode, or to the console in Super Dev Mode. Calls are optimized out in Production Mode.

Samson answered 4/2, 2015 at 14:18 Comment(1)
Also consider the juli logging: gwtproject.org/doc/latest/DevGuideLogging.htmlBottle

© 2022 - 2024 — McMap. All rights reserved.