HBASE-20577 Make Log Level page design consistent with the design of other pages in UI

Signed-off-by: tedyu <yuzhihong@gmail.com>
This commit is contained in:
Nihal Jain 2018-05-17 02:24:09 +05:30 committed by tedyu
parent acbc3a2253
commit 60bdaf7846
1 changed files with 33 additions and 15 deletions

View File

@ -105,13 +105,17 @@ public final class LogLevel {
response)) { response)) {
return; return;
} }
response.setContentType("text/html");
String requestedURL = "header.jsp?pageTitle=Log Level";
request.getRequestDispatcher(requestedURL).include(request, response);
PrintWriter out = response.getWriter();
out.println(FORMS);
PrintWriter out = ServletUtil.initHTML(response, "Log Level");
String logName = ServletUtil.getParameter(request, "log"); String logName = ServletUtil.getParameter(request, "log");
String level = ServletUtil.getParameter(request, "level"); String level = ServletUtil.getParameter(request, "level");
if (logName != null) { if (logName != null) {
out.println("<br /><hr /><h3>Results</h3>"); out.println("<p>Results:</p>");
out.println(MARKER out.println(MARKER
+ "Submitted Log Name: <b>" + logName + "</b><br />"); + "Submitted Log Name: <b>" + logName + "</b><br />");
@ -132,28 +136,42 @@ public final class LogLevel {
out.println("Sorry, " + log.getClass() + " not supported.<br />"); out.println("Sorry, " + log.getClass() + " not supported.<br />");
} }
} }
out.println("</div>");
out.println(FORMS); request.getRequestDispatcher("footer.jsp").include(request, response);
out.println(ServletUtil.HTML_TAIL); out.close();
} }
static final String FORMS = "\n<br /><hr /><h3>Get / Set</h3>" static final String FORMS = "<div class='container-fluid content'>\n"
+ "\n<form>Log: <input type='text' size='50' name='log' /> " + "<div class='row inner_header'>\n" + "<div class='page-header'>\n"
+ "<input type='submit' value='Get Log Level' />" + "<h1>Get/Set Log Level</h1>\n" + "</div>\n" + "</div>\n" + "Actions:" + "<p>"
+ "</form>" + "<center>\n" + "<table class='table' style='border: 0;' width='95%' >\n" + "<tr>\n"
+ "\n<form>Log: <input type='text' size='50' name='log' /> " + "<form>\n" + "<td class='centered'>\n"
+ "Level: <input type='text' name='level' /> " + "<input style='font-size: 12pt; width: 10em' type='submit' value='Get Log Level'"
+ "<input type='submit' value='Set Log Level' />" + " class='btn' />\n" + "</td>\n" + "<td style='text-align: center;'>\n"
+ "</form>"; + "<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, private static void process(org.apache.log4j.Logger log, String level,
PrintWriter out) throws IOException { PrintWriter out) throws IOException {
if (level != null) { if (level != null) {
if (!level.equals(org.apache.log4j.Level.toLevel(level).toString())) { 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 { } else {
log.setLevel(org.apache.log4j.Level.toLevel(level)); 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 out.println(MARKER