You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@livy.apache.org by js...@apache.org on 2017/08/02 08:48:50 UTC

incubator-livy git commit: [LIVY-387][WEB UI] Update Log page to split apart different logs

Repository: incubator-livy
Updated Branches:
  refs/heads/master 69300a2fe -> d48c0243e


[LIVY-387][WEB UI] Update Log page to split apart different logs

[LIVY-387](https://issues.cloudera.org/browse/LIVY-387)

Added javascript string parsing that finds the stdout, stderr, and YARN Diagnostics sections of the log and displays them in separate scrollable `<pre>` tags.

The `<pre>` tags are set to `max-height: 80%`, this makes scrolling down to each log easy so there is no need for an anchor link at the top of the page, also 80% allows a good sized viewing window. Each log is also set to scroll to the bottom on page load.

Manually Tested

Screenshots
![screen shot 2017-08-01 at 2 58 50 pm](https://user-images.githubusercontent.com/13952758/28849018-f873e4b2-76c9-11e7-8c3c-a7ffded90136.png)
[more will be added tomorrow when I can use my desktop monitor for different sized screenshots, I'm currently working from my laptop]

Author: Alex Bozarth <aj...@us.ibm.com>

Closes #27 from ajbozarth/log2.


Project: http://git-wip-us.apache.org/repos/asf/incubator-livy/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-livy/commit/d48c0243
Tree: http://git-wip-us.apache.org/repos/asf/incubator-livy/tree/d48c0243
Diff: http://git-wip-us.apache.org/repos/asf/incubator-livy/diff/d48c0243

Branch: refs/heads/master
Commit: d48c0243eb07999a2f61972198a430b68b622307
Parents: 69300a2
Author: Alex Bozarth <aj...@us.ibm.com>
Authored: Wed Aug 2 16:48:41 2017 +0800
Committer: jerryshao <ss...@hortonworks.com>
Committed: Wed Aug 2 16:48:41 2017 +0800

----------------------------------------------------------------------
 .../livy/server/ui/static/css/livy-ui.css       |  9 ++++
 .../livy/server/ui/static/js/session-log.js     | 43 +++++++++++++++++++-
 2 files changed, 50 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-livy/blob/d48c0243/server/src/main/resources/org/apache/livy/server/ui/static/css/livy-ui.css
----------------------------------------------------------------------
diff --git a/server/src/main/resources/org/apache/livy/server/ui/static/css/livy-ui.css b/server/src/main/resources/org/apache/livy/server/ui/static/css/livy-ui.css
index 9fa9556..fc2ca30 100644
--- a/server/src/main/resources/org/apache/livy/server/ui/static/css/livy-ui.css
+++ b/server/src/main/resources/org/apache/livy/server/ui/static/css/livy-ui.css
@@ -28,6 +28,15 @@ pre {
   white-space: pre-wrap;
 }
 
+#session-log pre {
+  max-height: 80%;
+  overflow: scroll;
+}
+
+#session-log h4 div {
+  display: inline-block;
+}
+
 td .progress {
   margin: 0;
 }

http://git-wip-us.apache.org/repos/asf/incubator-livy/blob/d48c0243/server/src/main/resources/org/apache/livy/server/ui/static/js/session-log.js
----------------------------------------------------------------------
diff --git a/server/src/main/resources/org/apache/livy/server/ui/static/js/session-log.js b/server/src/main/resources/org/apache/livy/server/ui/static/js/session-log.js
index b236938..a3072f9 100644
--- a/server/src/main/resources/org/apache/livy/server/ui/static/js/session-log.js
+++ b/server/src/main/resources/org/apache/livy/server/ui/static/js/session-log.js
@@ -25,9 +25,44 @@ function getLogPath(type, id) {
   }
 }
 
+function logHeader(name) {
+  return "<h4><div data-toggle='tooltip' data-placement='right' "
+    + "title='Only the most recent log lines are displayed "
+    + "(max log lines is set by the livy.cache-log.size config)'>"
+    + name + "</div></h4>";
+}
+
 function parseLog(logLines) {
-  // TODO: [LIVY-387]: Separate out stdout, stderr, and YARN Diagnostics into different viewers
-  return preWrap(logLines.join("\n"));
+  // display non-standard log formats
+  if (!logLines[0].startsWith("stdout")) {
+    return preWrap(logLines.join("\n"));
+  }
+
+  var stderrIndex = 0;
+  var stdoutLines = logLines;
+  var stderrLines = [];
+  var yarnDiagLines = null;
+
+  for (var i = 1; i < logLines.length; i++) {
+    if (stderrIndex == 0 && logLines[i].startsWith("\nstderr")) {
+      stdoutLines = logLines.slice(1, i);
+      stderrLines = logLines.slice(i, logLines.length);
+      stderrIndex = i;
+    } else if (logLines[i].startsWith("\nYARN Diagnostics")) {
+      stderrLines = logLines.slice(stderrIndex + 1, i);
+      yarnDiagLines = logLines.slice(i + 1, logLines.length);
+      break;
+    }
+  }
+
+  var stdoutLog = logHeader("stdout") + preWrap(stdoutLines.join("\n"));
+  var stderrLog = logHeader("stderr") + preWrap(stderrLines.join("\n"));
+  var yarnDiagLog = "";
+  if (yarnDiagLines != null) {
+    yarnDiagLog = "<h4>YARN Diagnostics</h4>" + preWrap(yarnDiagLines.join("\n"));
+  }
+
+  return stdoutLog + stderrLog + yarnDiagLog;
 }
 
 $(document).ready(function () {
@@ -38,6 +73,10 @@ $(document).ready(function () {
   $.getJSON(location.origin + getLogPath(type, id), {size: -1}, function(response) {
     if (response) {
       $("#session-log").append(parseLog(response.log));
+      $('#session-log [data-toggle="tooltip"]').tooltip();
+      $("#session-log pre").each(function () {
+          $(this).scrollTop($(this)[0].scrollHeight);
+      });
     }
   });
 });
\ No newline at end of file