Im new to the GWT framework which my project is using now. I wanted to trace the code flow and hence thought I could put System.out logs or debug logs. But nothing worked. Then I came accross this page and saw its tottaly differnet for logging. I added,
Debug.Java
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 ); }-*/;
}
and called inside my class
Frame.java
public void onModuleLoad() {
logSC("@@@@ onModuleLoad");
Debug.enable();
Debug.log("&&&&&&&INSIDE BICC******DEBUG LOGGERRRRRRRRR**************************");
}
But I didnt get the debug logs. Could you please advise me what should i do to enable logs and get printed in my console window.
Regards, Saranya Chandrasekaran
The
console.logcall in your JSNI needs a$wnd.prefix so that it runs on the correct window (gwt defaults to sandboxing its code in an iframe).Note that using JsInterop will not have this issue - add elemental2-core to your project, and call
DomGlobal.console.log()and it will already work in the main window.