cziegeler 01/07/17 03:11:12
Modified: src/org/apache/cocoon Cocoon.java
Log:
Added the code from the submitted DebugAction to the core, so the
information is always logged.
Submitted by: Marcus Crafter ([EMAIL PROTECTED])
Revision Changes Path
1.17 +71 -1 xml-cocoon2/src/org/apache/cocoon/Cocoon.java
Index: Cocoon.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/Cocoon.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- Cocoon.java 2001/07/09 13:19:47 1.16
+++ Cocoon.java 2001/07/17 10:11:11 1.17
@@ -17,6 +17,7 @@
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.Map;
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.component.Component;
@@ -41,6 +42,8 @@
import org.apache.cocoon.components.source.SourceHandler;
import org.apache.cocoon.components.source.URLSource;
import org.apache.cocoon.environment.Environment;
+import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.environment.Session;
import org.apache.cocoon.environment.Source;
import org.apache.cocoon.serialization.Serializer;
import org.apache.cocoon.sitemap.Manager;
@@ -57,7 +60,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a> (Apache
Software Foundation, Exoffice Technologies)
* @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
- * @version CVS $Revision: 1.16 $ $Date: 2001/07/09 13:19:47 $
+ * @version CVS $Revision: 1.17 $ $Date: 2001/07/17 10:11:11 $
*/
public class Cocoon extends AbstractLoggable implements ThreadSafe, Component,
Initializable, Disposable, Modifiable, Processor, Contextualizable {
/** The application context */
@@ -346,11 +349,77 @@
}
/**
+ * Log debug information about the current environment
+ */
+ protected void debug(Environment environment,
+ StreamPipeline pipeline,
+ EventPipeline eventPipeline) {
+ if (this.getLogger().isDebugEnabled() == true) {
+ String lineSeparator = System.getProperty("line.separator");
+ Map objectModel = environment.getObjectModel();
+ Request request = (Request) objectModel.get(Constants.REQUEST_OBJECT);
+ Session session = request.getSession(false);
+ StringBuffer msg = new StringBuffer();
+ msg.append("DEBUGGING INFORMATION:").append(lineSeparator);
+ if (pipeline != null && eventPipeline != null) {
+ msg.append("INTERNAL ");
+ }
+ msg.append("REQUEST:
").append(request.getRequestURI()).append(lineSeparator).append(lineSeparator);
+ msg.append("CONTEXT PATH:
").append(request.getContextPath()).append(lineSeparator);
+ msg.append("SERVLET PATH:
").append(request.getServletPath()).append(lineSeparator);
+ msg.append("PATH INFO:
").append(request.getPathInfo()).append(lineSeparator).append(lineSeparator);
+
+ msg.append("REMOTE HOST:
").append(request.getRemoteHost()).append(lineSeparator);
+ msg.append("REMOTE ADDRESS:
").append(request.getRemoteAddr()).append(lineSeparator);
+ msg.append("REMOTE USER:
").append(request.getRemoteUser()).append(lineSeparator);
+ msg.append("REQUEST SESSION ID:
").append(request.getRequestedSessionId()).append(lineSeparator);
+ msg.append("REQUEST PREFERRED LOCALE:
").append(request.getLocale().toString()).append(lineSeparator);
+ msg.append("SERVER HOST:
").append(request.getServerName()).append(lineSeparator);
+ msg.append("SERVER PORT:
").append(request.getServerPort()).append(lineSeparator).append(lineSeparator);
+
+ msg.append("METHOD:
").append(request.getMethod()).append(lineSeparator);
+ msg.append("CONTENT LENGTH:
").append(request.getContentLength()).append(lineSeparator);
+ msg.append("PROTOCOL:
").append(request.getProtocol()).append(lineSeparator);
+ msg.append("SCHEME:
").append(request.getScheme()).append(lineSeparator);
+ msg.append("AUTH TYPE:
").append(request.getAuthType()).append(lineSeparator).append(lineSeparator);
+
+ // log all of the request parameters
+ Enumeration e = request.getParameterNames();
+
+ msg.append("REQUEST
PARAMETERS:").append(lineSeparator).append(lineSeparator);
+
+ while (e.hasMoreElements()) {
+ String p = (String) e.nextElement();
+
+ msg.append("PARAM: '").append(p).append("' ")
+ .append("VALUE:
'").append(request.getParameter(p)).append("'").append(lineSeparator);
+ }
+
+ msg.append(lineSeparator).append("SESSION
ATTRIBUTES:").append(lineSeparator).append(lineSeparator);
+
+ // log all of the session attributes
+ if (session != null) {
+ e = session.getAttributeNames();
+
+ while (e.hasMoreElements()) {
+ String p = (String) e.nextElement();
+
+ msg.append("PARAM: '").append(p).append("' ")
+ .append("VALUE:
'").append(session.getAttribute(p)).append("'").append(lineSeparator);
+ }
+ }
+
+ getLogger().debug(msg.toString());
+ }
+ }
+
+ /**
* Process the given <code>Environment</code> to produce the output.
*/
public boolean process(Environment environment)
throws Exception {
if (disposed) throw new IllegalStateException("You cannot process a
Disposed Cocoon engine.");
+ this.debug(environment, null, null);
return this.sitemapManager.invoke(this.componentManager, environment, "",
this.sitemapFileName,
this.checkSitemapReload, this.reloadSitemapAsynchron);
}
@@ -362,6 +431,7 @@
public boolean process(Environment environment, StreamPipeline pipeline,
EventPipeline eventPipeline)
throws Exception {
if (disposed) throw new IllegalStateException("You cannot process a
Disposed Cocoon engine.");
+ this.debug(environment, pipeline, eventPipeline);
return this.sitemapManager.invoke(this.componentManager, environment, "",
this.sitemapFileName,
this.checkSitemapReload, this.reloadSitemapAsynchron,
pipeline, eventPipeline);
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]