How to print to the console in GWT

前端 未结 10 1124
广开言路
广开言路 2020-12-23 14:29

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

10条回答
  •  我在风中等你
    2020-12-23 14:43

    I needed to do this in the context of a GWT application that was deployed to an Android device/emulator via PhoneGap (and gwt-phonegap). Neither System.out.println() nor GWT logging as above (with module declaration) showed up in Android's logcat, so I resorted to a simple JSNI wrapper to console.log:

      public void onModuleLoad()
      {
        Logger logger = Logger.getLogger("Test1.java");
        logger.log(Level.INFO, "ash: starting onModuleLoad (1)"); // not in logcat
        System.out.println( "ash: starting onModuleLoad (2)" ); // not in logcat
        consoleLog( "ash: starting onModuleLoad (3)" ); // This shows up
        ...
      }
    
      native void consoleLog( String message) /*-{
          console.log( "me:" + message );
      }-*/;
    

提交回复
热议问题