org.browsermob.proxy.jetty.servlet.Debug Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of browsermob-proxy Show documentation
Show all versions of browsermob-proxy Show documentation
A programmatic HTTP/S designed for performance and functional testing
// ===========================================================================
// Copyright (c) 1996 Mort Bay Consulting Pty. Ltd. All rights reserved.
// $Id: Debug.java,v 1.10 2005/08/13 00:01:28 gregwilkins Exp $
// ---------------------------------------------------------------------------
package org.browsermob.proxy.jetty.servlet;
import org.apache.commons.logging.Log;
import org.browsermob.proxy.jetty.html.*;
import org.browsermob.proxy.jetty.log.LogFactory;
import org.browsermob.proxy.jetty.log.LogImpl;
import org.browsermob.proxy.jetty.log.LogSink;
import org.browsermob.proxy.jetty.log.OutputStreamLogSink;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.Writer;
/* ------------------------------------------------------------ */
// Don't write servlets like this one :-)
public class Debug extends HttpServlet
{
/* ------------------------------------------------------------ */
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
Page page= new Page();
page.title(getServletInfo());
page.attribute("text","#000000");
page.attribute(Page.BGCOLOR,"#FFFFFF");
page.attribute("link","#606CC0");
page.attribute("vlink","#606CC0");
page.attribute("alink","#606CC0");
Log l = LogFactory.getLog(Debug.class);
if (!(l instanceof LogImpl))
return;
LogImpl log = (LogImpl) l;
TableForm tf = new TableForm(request.getRequestURI());
page.add(tf);
tf.table().newRow().addCell(new Block(Block.Bold)
.add(new Font(3,true).add(getServletInfo()))).cell().attribute("COLSPAN","2");
tf.table().add(Break.rule);
tf.addCheckbox("D","Debug On",log.getDebug());
tf.addTextField("V","Verbosity Level",6,""+log.getVerbose());
tf.addTextField("P","Debug Patterns",40,log.getDebugPatterns());
tf.addCheckbox("W","Suppress Warnings",log.getSuppressWarnings());
LogSink[] sinks = log.getLogSinks();
for (int s=0;sinks!=null && sLog Sink "+s+":0)
log.setVerbose(Integer.parseInt(v));
else
log.setVerbose(0);
log.setDebugPatterns(request.getParameter("P"));
LogSink[] sinks = log.getLogSinks();
for (int s=0;sinks!=null && s