I am debugging a GWT application and I need to print some stuff to the console for testing purposes. System.out.println
and GWT.log
don\'t work. Do
Yet another variation using the native console...
Add this class:
package XXX.XXX.XXX.XXX;
public class Debug {
private static boolean isEnabled_ = false;
public static void enable() { isEnabled_ = true; }
public static void setEnabled( final boolean isEnabled )
{ isEnabled_ = isEnabled; }
public static void log( final String s )
{ if( isEnabled_ ) nativeConsoleLog( s ); }
private static native void nativeConsoleLog( String s )
/*-{ console.log( s ); }-*/;
}
Then, enable debugging with it at some point, like upon starting the app:
public class XXXXXX implements EntryPoint {
@Override
public void onModuleLoad() {
Debug.enable();
...
}
}
Then just use it like so:
Debug.log("Hello World!");