General Interface is an open source project hosted by the Dojo Foundation

GI Contributor Blog Blog from Sep 03, 2009

  2009/09/03
Please, don't use alert(), use jsx3.log() instead.
Last Changed by Darren Hwang, Sep 03, 2009 19:36

Application Log Monitor

I keep seeing the use of alert() for debug logging purpose in the forums posts. I like to suggest that user don't do this. First, the use of alert() can disrupts asynchronous code executions and create undesirable side effect in AJAX framework such as GI. Second, GI has a easy to use and configure log monitor that can even be configured to pop up only when you press a special hotkeys combination. Third, logging to the log monitor is as easy as calling "jsx3.log()" instead of "alert()".

To enable the log monitor, follow these steps

  1. Locate under your "gi-3.8" the file "logger.xml", open this file for editing.
  2. Uncomment the <handler name="appMonitor1" ... section, while commenting out the "serverNamespace" property. This will enable the handler for any applications
       <handler name="appMonitor1" class="jsx3.app.Monitor" require="true">
        <!--property name="serverNamespace" value="myApp"/-->
        <property name="disableInIDE" eval="true" value="true"/>
        <property name="activateOnHotKey" eval="true" value="false"/>
        <property name="format" value="%t %n (%l) - %M"/>
      </handler>
    

    Optional : you can change the property activateOnHotKey to true to allow the use of keys Ctrl+Alt+m to open the log monitor

  3. Also uncomment the global logger's handler reference
      <logger name="global" level="INFO">
        <handler-ref name="memory"/>
        <handler-ref name="console"/>
        <handler-ref name="ide"/>
        <handler-ref name="fatal"/>
        <handler-ref name="appMonitor1"/>
      </logger>
    
  4. Add jsx3.log("some log message"); to your code
  5. Run your project

Firebug and IE8 developer tools console

An even easier option

As most of the advanced users already know, one of the single most useful tool for web application developer is Firebug, which allows the developer to send message to its log console. Since GI 3.7.1, there is a standard "Console" log handler defined for GI log messages. There's no configuration changes needed to be done on the logger.xml file, simply opening Firebug or IE developer tool will show you the log messages logged by jsx3.log() (or your own jsx3.util.Logger instance)

Posted at 03 Sep @ 6:55 PM by Darren Hwang | 0 Comments