HBASE-21830 Backport HBASE-20577 (Make Log Level page design consistent with the design of other pages in UI) to branch-2

Signed-off-by: zhangduo <zhangduo@apache.org>
This commit is contained in:
Nihal Jain 2019-02-02 17:09:39 +05:30 committed by zhangduo
parent 2fe2d55e77
commit 33b87d67eb
1 changed files with 45 additions and 14 deletions

View File

@ -18,6 +18,7 @@
package org.apache.hadoop.hbase.http.log;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
@ -105,13 +106,23 @@ public final class LogLevel {
response)) {
return;
}
response.setContentType("text/html");
PrintWriter out;
try {
String headerPath = "header.jsp?pageTitle=Log Level";
request.getRequestDispatcher(headerPath).include(request, response);
out = response.getWriter();
} catch (FileNotFoundException e) {
// in case file is not found fall back to old design
out = ServletUtil.initHTML(response, "Log Level");
}
out.println(FORMS);
PrintWriter out = ServletUtil.initHTML(response, "Log Level");
String logName = ServletUtil.getParameter(request, "log");
String level = ServletUtil.getParameter(request, "level");
if (logName != null) {
out.println("<br /><hr /><h3>Results</h3>");
out.println("<p>Results:</p>");
out.println(MARKER
+ "Submitted Log Name: <b>" + logName + "</b><br />");
@ -133,27 +144,47 @@ public final class LogLevel {
}
}
out.println(FORMS);
out.println(ServletUtil.HTML_TAIL);
try {
String footerPath = "footer.jsp";
out.println("</div>");
request.getRequestDispatcher(footerPath).include(request, response);
} catch (FileNotFoundException e) {
out.println(ServletUtil.HTML_TAIL);
}
out.close();
}
static final String FORMS = "\n<br /><hr /><h3>Get / Set</h3>"
+ "\n<form>Log: <input type='text' size='50' name='log' /> "
+ "<input type='submit' value='Get Log Level' />"
+ "</form>"
+ "\n<form>Log: <input type='text' size='50' name='log' /> "
+ "Level: <input type='text' name='level' /> "
+ "<input type='submit' value='Set Log Level' />"
+ "</form>";
static final String FORMS = "<div class='container-fluid content'>\n"
+ "<div class='row inner_header'>\n" + "<div class='page-header'>\n"
+ "<h1>Get/Set Log Level</h1>\n" + "</div>\n" + "</div>\n" + "Actions:" + "<p>"
+ "<center>\n" + "<table class='table' style='border: 0;' width='95%' >\n" + "<tr>\n"
+ "<form>\n" + "<td class='centered'>\n"
+ "<input style='font-size: 12pt; width: 10em' type='submit' value='Get Log Level'"
+ " class='btn' />\n" + "</td>\n" + "<td style='text-align: center;'>\n"
+ "<input type='text' name='log' size='50' required='required'"
+ " placeholder='Log Name (required)' />\n" + "</td>\n" + "<td width=\"40%\">"
+ "Get the current log level for the specified log name." + "</td>\n" + "</form>\n"
+ "</tr>\n" + "<tr>\n" + "<form>\n" + "<td class='centered'>\n"
+ "<input style='font-size: 12pt; width: 10em' type='submit'"
+ " value='Set Log Level' class='btn' />\n" + "</td>\n"
+ "<td style='text-align: center;'>\n"
+ "<input type='text' name='log' size='50' required='required'"
+ " placeholder='Log Name (required)' />\n"
+ "<input type='text' name='level' size='50' required='required'"
+ " placeholder='Log Level (required)' />\n" + "</td>\n" + "<td width=\"40%\" style=\"\">"
+ "Set the specified log level for the specified log name." + "</td>\n" + "</form>\n"
+ "</tr>\n" + "</table>\n" + "</center>\n" + "</p>\n" + "<hr/>\n";
private static void process(org.apache.log4j.Logger log, String level,
PrintWriter out) throws IOException {
if (level != null) {
if (!level.equals(org.apache.log4j.Level.toLevel(level).toString())) {
out.println(MARKER + "Bad level : <b>" + level + "</b><br />");
out.println(MARKER + "<div class='text-danger'>" + "Bad level : <strong>" + level
+ "</strong><br />" + "</div>");
} else {
log.setLevel(org.apache.log4j.Level.toLevel(level));
out.println(MARKER + "Setting Level to " + level + " ...<br />");
out.println(MARKER + "<div class='text-success'>" + "Setting Level to <strong>" + level
+ "</strong> ...<br />" + "</div>");
}
}
out.println(MARKER