B2G/gecko/toolkit/devtools/Console.jsm
/**
 * A multi line stringification of an object, designed for use by humans
 *
 * @param {any} aThing
 *        The object to be stringified
 * @return {string}
 *        A multi line representation of aThing
 */
A multi line stringification of an object, designed for use by humans
@param {any} aThing
The object to be stringified
@return {string}
A multi line representation of aThing
A multi line stringification of an object designed for use by humans @param { any } aThing The object to be stringified @return { string } A multi line representation of aThing
function log(aThing) {
  if (aThing === null) {
    return "null\n";
  }
  if (aThing === undefined) {
    return "undefined\n";
  }
  if (typeof aThing == "object") {
    let reply = "";
    let type = getCtorName(aThing);
    if (type == "Error") {
      reply += "  " + aThing.message + "\n";
      reply += logProperty("stack", aThing.stack);
    }
    else if (aThing instanceof Components.interfaces.nsIDOMNode && aThing.tagName) {
      reply += "  " + debugElement(aThing) + "\n";
    }
    else {
      let keys = Object.getOwnPropertyNames(aThing);
      if (keys.length > 0) {
        reply += type + "\n";
        keys.forEach(function(aProp) {
          reply += logProperty(aProp, aThing[aProp]);
        }, this);
      }
      else {
        reply += type + "\n";
        let root = aThing;
        let logged = [];
        while (root != null) {
          let properties = Object.keys(root);
          properties.sort();
          properties.forEach(function(property) {
            if (!(property in logged)) {
              logged[property] = property;
              reply += logProperty(property, aThing[property]);
            }
          });
          root = Object.getPrototypeOf(root);
          if (root != null) {
            reply += '  - prototype ' + getCtorName(root) + '\n';
          }
        }
      }
    }
    return reply;
  }
  return "  " + aThing.toString() + "\n";
}
function log ( aThing ) { if ( aThing === null ) { return "null\n" ; } if ( aThing === undefined ) { return "undefined\n" ; } if ( typeof aThing == "object" ) { let reply = "" ; let type = getCtorName ( aThing ) ; if ( type == "Error" ) { reply += "  " + aThing . message + "\n" ; reply += logProperty ( "stack" , aThing . stack ) ; } else if ( aThing instanceof Components . interfaces . nsIDOMNode && aThing . tagName ) { reply += "  " + debugElement ( aThing ) + "\n" ; } else { let keys = Object . getOwnPropertyNames ( aThing ) ; if ( keys . length > 0 ) { reply += type + "\n" ; keys . forEach ( function ( aProp ) { reply += logProperty ( aProp , aThing [ aProp ] ) ; } , this ) ; } else { reply += type + "\n" ; let root = aThing ; let logged = [ ] ; while ( root != null ) { let properties = Object . keys ( root ) ; properties . sort ( ) ; properties . forEach ( function ( property ) { if ( ! ( property in logged ) ) { logged [ property ] = property ; reply += logProperty ( property , aThing [ property ] ) ; } } ) ; root = Object . getPrototypeOf ( root ) ; if ( root != null ) { reply += '  - prototype ' + getCtorName ( root ) + '\n' ; } } } } return reply ; } return "  " + aThing . toString ( ) + "\n" ; }
A multi line stringification of an object, designed for use by humans
 @param {any} aThing
        The object to be stringified
 @return {string}
        A multi line representation of aThing
A multi line stringification of an object designed for use by humans @param { any } aThing The object to be stringified @return { string } A multi line representation of aThing