B2G/gecko/browser/devtools/webconsole/webconsole.js
/**
   * Logs a message to the Web Console that originates from the Web Console
   * server.
   *
   * @param object aMessage
   *        The message received from the server.
   * @return nsIDOMElement|undefined
   *         The message element to display in the Web Console output.
   */
Logs a message to the Web Console that originates from the Web Console
server.

@param object aMessage
The message received from the server.
@return nsIDOMElement|undefined
The message element to display in the Web Console output.
Logs a message to the Web Console that originates from the Web Console server . @param object aMessage The message received from the server . @return nsIDOMElement|undefined The message element to display in the Web Console output .
function WCF_logConsoleAPIMessage(aMessage)
  {
    let body = null;
    let clipboardText = null;
    let sourceURL = null;
    let sourceLine = 0;
    let level = aMessage.level;
    let args = aMessage.arguments;
    let objectActors = [];
    switch (level) {
      case "log":
      case "info":
      case "warn":
      case "error":
      case "debug":
      case "dir":
      case "groupEnd": {
        body = { arguments: args };
        let clipboardArray = [];
        args.forEach(function(aValue) {
          clipboardArray.push(WebConsoleUtils.objectActorGripToString(aValue));
          if (aValue && typeof aValue == "object" && aValue.actor) {
            objectActors.push(aValue.actor);
          }
        }, this);
        clipboardText = clipboardArray.join(" ");
        sourceURL = aMessage.filename;
        sourceLine = aMessage.lineNumber;
        if (level == "dir") {
          body.objectProperties = aMessage.objectProperties;
        }
        else if (level == "groupEnd") {
          objectActors.forEach(this._releaseObject, this);
          if (this.groupDepth > 0) {
            this.groupDepth--;
          }
          return; 
        }
        break;
      }
      case "trace": {
        let filename = WebConsoleUtils.abbreviateSourceURL(args[0].filename);
        let functionName = args[0].functionName ||
                           l10n.getStr("stacktrace.anonymousFunction");
        let lineNumber = args[0].lineNumber;
        body = l10n.getFormatStr("stacktrace.outputMessage",
                                 [filename, functionName, lineNumber]);
        sourceURL = args[0].filename;
        sourceLine = args[0].lineNumber;
        clipboardText = "";
        args.forEach(function(aFrame) {
          clipboardText += aFrame.filename + " :: " +
                           aFrame.functionName + " :: " +
                           aFrame.lineNumber + "\n";
        });
        clipboardText = clipboardText.trimRight();
        break;
      }
      case "group":
      case "groupCollapsed":
        clipboardText = body = args;
        sourceURL = aMessage.filename;
        sourceLine = aMessage.lineNumber;
        this.groupDepth++;
        break;
      case "time":
        if (!args) {
          return;
        }
        if (args.error) {
          Cu.reportError(l10n.getStr(args.error));
          return;
        }
        body = l10n.getFormatStr("timerStarted", [args.name]);
        clipboardText = body;
        sourceURL = aMessage.filename;
        sourceLine = aMessage.lineNumber;
        break;
      case "timeEnd":
        if (!args) {
          return;
        }
        body = l10n.getFormatStr("timeEnd", [args.name, args.duration]);
        clipboardText = body;
        sourceURL = aMessage.filename;
        sourceLine = aMessage.lineNumber;
        break;
      default:
        Cu.reportError("Unknown Console API log level: " + level);
        return;
    }
    let node = this.createMessageNode(CATEGORY_WEBDEV, LEVELS[level], body,
                                      sourceURL, sourceLine, clipboardText,
                                      level, aMessage.timeStamp);
    if (objectActors.length) {
      node._objectActors = objectActors;
    }
    if (level == "trace") {
      node._stacktrace = args;
      this.makeOutputMessageLink(node, function _traceNodeClickCallback() {
        if (node._panelOpen) {
          return;
        }
        let options = {
          anchor: node,
          data: { object: node._stacktrace },
        };
        let propPanel = this.jsterm.openPropertyPanel(options);
        propPanel.panel.setAttribute("hudId", this.hudId);
      }.bind(this));
    }
    if (level == "dir") {
      node._onOutput = function _onMessageOutput() {
        node.querySelector("tree").view = node.propertyTreeView;
      };
    }
    return node;
  }
function WCF_logConsoleAPIMessage ( aMessage ) { let body = null ; let clipboardText = null ; let sourceURL = null ; let sourceLine = 0 ; let level = aMessage . level ; let args = aMessage . arguments ; let objectActors = [ ] ; switch ( level ) { case "log" : case "info" : case "warn" : case "error" : case "debug" : case "dir" : case "groupEnd" : { body = { arguments : args } ; let clipboardArray = [ ] ; args . forEach ( function ( aValue ) { clipboardArray . push ( WebConsoleUtils . objectActorGripToString ( aValue ) ) ; if ( aValue && typeof aValue == "object" && aValue . actor ) { objectActors . push ( aValue . actor ) ; } } , this ) ; clipboardText = clipboardArray . join ( " " ) ; sourceURL = aMessage . filename ; sourceLine = aMessage . lineNumber ; if ( level == "dir" ) { body . objectProperties = aMessage . objectProperties ; } else if ( level == "groupEnd" ) { objectActors . forEach ( this . _releaseObject , this ) ; if ( this . groupDepth > 0 ) { this . groupDepth -- ; } return ; } break ; } case "trace" : { let filename = WebConsoleUtils . abbreviateSourceURL ( args [ 0 ] . filename ) ; let functionName = args [ 0 ] . functionName || l10n . getStr ( "stacktrace.anonymousFunction" ) ; let lineNumber = args [ 0 ] . lineNumber ; body = l10n . getFormatStr ( "stacktrace.outputMessage" , [ filename , functionName , lineNumber ] ) ; sourceURL = args [ 0 ] . filename ; sourceLine = args [ 0 ] . lineNumber ; clipboardText = "" ; args . forEach ( function ( aFrame ) { clipboardText += aFrame . filename + " :: " + aFrame . functionName + " :: " + aFrame . lineNumber + "\n" ; } ) ; clipboardText = clipboardText . trimRight ( ) ; break ; } case "group" : case "groupCollapsed" : clipboardText = body = args ; sourceURL = aMessage . filename ; sourceLine = aMessage . lineNumber ; this . groupDepth ++ ; break ; case "time" : if ( ! args ) { return ; } if ( args . error ) { Cu . reportError ( l10n . getStr ( args . error ) ) ; return ; } body = l10n . getFormatStr ( "timerStarted" , [ args . name ] ) ; clipboardText = body ; sourceURL = aMessage . filename ; sourceLine = aMessage . lineNumber ; break ; case "timeEnd" : if ( ! args ) { return ; } body = l10n . getFormatStr ( "timeEnd" , [ args . name , args . duration ] ) ; clipboardText = body ; sourceURL = aMessage . filename ; sourceLine = aMessage . lineNumber ; break ; default : Cu . reportError ( "Unknown Console API log level: " + level ) ; return ; } let node = this . createMessageNode ( CATEGORY_WEBDEV , LEVELS [ level ] , body , sourceURL , sourceLine , clipboardText , level , aMessage . timeStamp ) ; if ( objectActors . length ) { node . _objectActors = objectActors ; } if ( level == "trace" ) { node . _stacktrace = args ; this . makeOutputMessageLink ( node , function _traceNodeClickCallback ( ) { if ( node . _panelOpen ) { return ; } let options = { anchor : node , data : { object : node . _stacktrace } , } ; let propPanel = this . jsterm . openPropertyPanel ( options ) ; propPanel . panel . setAttribute ( "hudId" , this . hudId ) ; } . bind ( this ) ) ; } if ( level == "dir" ) { node . _onOutput = function _onMessageOutput ( ) { node . querySelector ( "tree" ) . view = node . propertyTreeView ; } ; } return node ; }
Logs a message to the Web Console that originates from the Web Console
 server.
Logs a message to the Web Console that originates from the Web Console server .
// no need to continue // Make the node bring up the property panel, to allow the user to inspect // the stack trace. // Initialize the inspector message node, by setting the PropertyTreeView // object on the tree view. This has to be done *after* the node is // shown, because the tree binding must be attached first.