Guest
Welcome login


TIBCOmmunity > Blogs > General Interface Blog > 2009 > July > 21
Home   Members Communities

General Interface Blog

General Interface Blog

Previous Next
Authority
0

Creating a Firebug Log Handler

Posted by Darren Hwang Jul 21, 2009 2:49:51 PM

I had this in the draft for a while.. It is actually no longer relavant in 3.7.1. However, I think it may be relavant in a different context of how to create your own custom log handler. So I'm post this now..

 

While GI always had its own log monitor, it is still useful to be able to log to Firebug which is the single most useful development tool for web devlopers. This is a new log handle introduced in GI 3.7.1, however, what if you're not using 3.7.1? Well the code will still work previous version of GI

 

It is important that this class be loaded at the very beginning, so you want to add this to the JSX/js/fx/jsx.js file

 

/**
 * Handles a logging record by sending it to the Firebug console.
 */
jsx3.Class.defineClass('jsx3.util.ConsoleHandler', jsx3.util.Logger.FormatHandler,  nul l,
    function(ConsoleHandler, ConsoleHandler_prototype) {
 
  // maps logger levels to console method names
  var methods = [nul l, "error", "error", "warn", "info", "debug", "debug"];
 
  ConsoleHandler_prototype.handle = function(objRecord) {
    if (window.console) {
      var method = methods[objRecord.getLevel()];
      if (method) {
        try {
          console[method](this.format(objRecord));
        } catch (e) {}
      }
    }
  };
 
});

 

 

Logger.xml

 


  <!-- Logs messages to the Firebug console, when available. -->
  <handler name="console" class="jsx3.util.ConsoleHandler"/>

 <!-- The global logger. -->
  <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>

 

There are no comments on this post



General Interface Blog

General Interface Blog