logMessageIntoHTMLBodyComment static method

dynamic logMessageIntoHTMLBodyComment(
  1. String message, [
  2. Node? node
])

adds a debug message into the body of the HTML page or a specified node.

Implementation

static logMessageIntoHTMLBodyComment(String message, [Node? node]) {
/*
  log.info(
      'Function : logMessageIntoHTMLBodyComment, '
          'Parameters : {[message,$message][element,$node.nodeName]}');
*/
  //use supplied node or last node in HTML body
  Node? targetNode = node;
  if (targetNode == null) {
    targetNode = document.body!.childNodes.last;
  }
  //append to existing comment or create new comment node
  if (targetNode.nodeName != '#comment') {
    document.body!.append(new Comment(message));
  } else {
    try {
      targetNode.text = targetNode.text! + "\n" + message;
    } catch (exception) {
      document.body!.append(new Comment(message));
    }
  }
/*
  log.fine('Function : logMessageIntoHTMLBodyComment, Return : void');
*/
}