cziegeler 01/08/13 01:41:05
Modified: src/org/apache/cocoon/servlet Tag: cocoon_20_branch
CocoonServlet.java
src/org/apache/cocoon/util/log Tag: cocoon_20_branch
CocoonLogFormatter.java
ExtensiblePatternFormatter.java
XMLCocoonLogFormatter.java
Added: lib Tag: cocoon_20_branch logkit-1.0b4.jar
Removed: lib Tag: cocoon_20_branch logkit-1.0b3.jar
Log:
Updated to LogKit B4
Revision Changes Path
No revision
No revision
1.1.2.1 +0 -0 xml-cocoon2/lib/logkit-1.0b4.jar
<<Binary file>>
No revision
No revision
1.13.2.14 +8 -9 xml-cocoon2/src/org/apache/cocoon/servlet/CocoonServlet.java
Index: CocoonServlet.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/servlet/CocoonServlet.java,v
retrieving revision 1.13.2.13
retrieving revision 1.13.2.14
diff -u -r1.13.2.13 -r1.13.2.14
--- CocoonServlet.java 2001/08/10 12:21:57 1.13.2.13
+++ CocoonServlet.java 2001/08/13 08:41:05 1.13.2.14
@@ -44,14 +44,14 @@
import org.apache.cocoon.util.NetUtils;
import org.apache.cocoon.util.log.CocoonLogFormatter;
import org.apache.cocoon.util.log.XMLCocoonLogFormatter;
-import org.apache.log.ContextStack;
+import org.apache.log.ContextMap;
import org.apache.log.Formatter;
import org.apache.log.Hierarchy;
import org.apache.log.LogTarget;
import org.apache.log.Logger;
import org.apache.log.Priority;
import org.apache.log.filter.PriorityFilter;
-import org.apache.log.output.FileOutputLogTarget;
+import org.apache.log.output.io.FileTarget;
import org.apache.log.output.ServletOutputLogTarget;
import org.xml.sax.SAXException;
@@ -64,7 +64,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Nicola Ken Barozzi</a> Aisa
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
- * @version CVS $Revision: 1.13.2.13 $ $Date: 2001/08/10 12:21:57 $
+ * @version CVS $Revision: 1.13.2.14 $ $Date: 2001/08/13 08:41:05 $
*/
public class CocoonServlet extends HttpServlet {
@@ -377,10 +377,9 @@
this.log = Hierarchy.getDefaultHierarchy().getLoggerFor("cocoon");
this.log.setPriority(logPriority);
- FileOutputLogTarget fileTarget = new FileOutputLogTarget(path);
+ FileTarget fileTarget = new FileTarget(new File(path), false,
formatter);
ServletOutputLogTarget servTarget = new
ServletOutputLogTarget(this.servletContext);
- fileTarget.setFormatter(formatter);
servTarget.setFormatter(formatter);
PriorityFilter filter = new PriorityFilter(Priority.ERROR);
@@ -525,12 +524,12 @@
// Initialize a fresh log context containing the object model : it
// will be used by the CocoonLogFormatter
- ContextStack ctxStack = org.apache.log.ContextStack.getCurrentContext();
- ctxStack.clear();
+ ContextMap ctxMap = org.apache.log.ContextMap.getCurrentContext();
+ ctxMap.clear();
// Add thread name (default content for empty context)
- ctxStack.push(Thread.currentThread().getName());
+ ctxMap.set("threadName", Thread.currentThread().getName());
// Add the object model
- ctxStack.push(env.getObjectModel());
+ ctxMap.set("objectModel", env.getObjectModel());
if (this.cocoon.process(env)) {
processed = true;
No revision
No revision
1.3.2.3 +13 -14
xml-cocoon2/src/org/apache/cocoon/util/log/CocoonLogFormatter.java
Index: CocoonLogFormatter.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/util/log/CocoonLogFormatter.java,v
retrieving revision 1.3.2.2
retrieving revision 1.3.2.3
diff -u -r1.3.2.2 -r1.3.2.3
--- CocoonLogFormatter.java 2001/08/13 05:57:56 1.3.2.2
+++ CocoonLogFormatter.java 2001/08/13 08:41:05 1.3.2.3
@@ -17,7 +17,7 @@
import org.apache.cocoon.Constants;
import org.apache.cocoon.environment.Request;
-import org.apache.log.ContextStack;
+import org.apache.log.ContextMap;
import org.apache.log.LogEvent;
/**
@@ -34,7 +34,7 @@
* </ul>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a>
- * @version CVS $Revision: 1.3.2.2 $ $Date: 2001/08/13 05:57:56 $
+ * @version CVS $Revision: 1.3.2.3 $ $Date: 2001/08/13 08:41:05 $
*/
public class CocoonLogFormatter extends ExtensiblePatternFormatter
@@ -101,10 +101,10 @@
return getClass(run.m_format);
case TYPE_URI :
- return getURI(event.getContextStack());
+ return getURI(event.getContextMap());
case TYPE_THREAD :
- return getThread(event.getContextStack());
+ return getThread(event.getContextMap());
}
return super.formatPatternRun(event, run);
@@ -144,14 +144,13 @@
/**
* Find the URI that is being processed.
*/
-
- private String getURI(ContextStack ctxStack) {
+ private String getURI(ContextMap ctxMap) {
String result = "Unknown-URI";
- // Get URI from the first context stack element, if it's a Map (the object
model).
- if (ctxStack.getSize() > 1) {
- Object context = ctxStack.get(1);
- if (context instanceof Map) {
+ // Get URI from the the object model.
+ if (ctxMap != null) {
+ Object context = ctxMap.get("objectModel");
+ if (context != null && context instanceof Map) {
// Get the request
Request request =
(Request)((Map)context).get(Constants.REQUEST_OBJECT);
if (request != null) {
@@ -163,13 +162,13 @@
return result;
}
+
/**
* Find the thread that is logged this event.
*/
-
- private String getThread(ContextStack ctxStack) {
- if (ctxStack.getSize() > 0)
- return String.valueOf(ctxStack.get(0));
+ private String getThread(ContextMap ctxMap) {
+ if (ctxMap != null && ctxMap.get("threadName") != null)
+ return (String)ctxMap.get("threadName");
else
return "Unknown-thread";
}
1.3.2.2 +1 -43
xml-cocoon2/src/org/apache/cocoon/util/log/ExtensiblePatternFormatter.java
Index: ExtensiblePatternFormatter.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/util/log/ExtensiblePatternFormatter.java,v
retrieving revision 1.3.2.1
retrieving revision 1.3.2.2
diff -u -r1.3.2.1 -r1.3.2.2
--- ExtensiblePatternFormatter.java 2001/08/08 09:55:42 1.3.2.1
+++ ExtensiblePatternFormatter.java 2001/08/13 08:41:05 1.3.2.2
@@ -28,14 +28,13 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a>
- * @version CVS $Revision: 1.3.2.1 $ $Date: 2001/08/08 09:55:42 $
+ * @version CVS $Revision: 1.3.2.2 $ $Date: 2001/08/13 08:41:05 $
*/
public class ExtensiblePatternFormatter
implements Formatter
{
protected final static int TYPE_TEXT = 1;
protected final static int TYPE_CATEGORY = 2;
- protected final static int TYPE_CONTEXT = 3;
protected final static int TYPE_MESSAGE = 4;
protected final static int TYPE_TIME = 5;
protected final static int TYPE_RELATIVE_TIME = 6;
@@ -50,7 +49,6 @@
protected final static String TYPE_CATEGORY_STR = "category";
- protected final static String TYPE_CONTEXT_STR = "context";
protected final static String TYPE_MESSAGE_STR = "message";
protected final static String TYPE_TIME_STR = "time";
protected final static String TYPE_RELATIVE_TIME_STR = "rtime";
@@ -369,10 +367,6 @@
str = getMessage( event.getMessage(), run.m_format );
break;
- case TYPE_CONTEXT:
- str = getContext( event.getContextStack(), run.m_format );
- break;
-
case TYPE_CATEGORY:
str = getCategory( event.getCategory(), run.m_format );
break;
@@ -410,41 +404,6 @@
}
/**
- * Utility method to format context.
- *
- * @param context the context string
- * @param format ancilliary format parameter - allowed to be null
- * @return the formatted string
- */
- protected String getContext( final ContextStack stack, final String format )
- {
- //TODO: Retrieve StringBuffers from a cache
- final StringBuffer sb = new StringBuffer();
- final int size = stack.getSize();
-
- int sizeSpecification = Integer.MAX_VALUE;
-
- if( null != format )
- {
- try { sizeSpecification = Integer.parseInt( format ); }
- catch( final NumberFormatException nfe ) { nfe.printStackTrace(); }
- }
-
- final int end = size - 1;
- final int start = Math.max( end - sizeSpecification + 1, 0 );
-
- for( int i = start; i < end; i++ )
- {
- sb.append( fix( stack.get( i ).toString() ) );
- sb.append( '.' );
- }
-
- sb.append( stack.get( end ) );
-
- return sb.toString();
- }
-
- /**
* Correct a context string by replacing '.''s with a '_'.
*
* @param context the un-fixed context
@@ -503,7 +462,6 @@
protected int getTypeIdFor( final String type )
{
if( type.equalsIgnoreCase( TYPE_CATEGORY_STR ) ) return TYPE_CATEGORY;
- else if( type.equalsIgnoreCase( TYPE_CONTEXT_STR ) ) return TYPE_CONTEXT;
else if( type.equalsIgnoreCase( TYPE_MESSAGE_STR ) ) return TYPE_MESSAGE;
else if( type.equalsIgnoreCase( TYPE_PRIORITY_STR ) ) return TYPE_PRIORITY;
else if( type.equalsIgnoreCase( TYPE_TIME_STR ) ) return TYPE_TIME;
1.1.2.4 +27 -46
xml-cocoon2/src/org/apache/cocoon/util/log/XMLCocoonLogFormatter.java
Index: XMLCocoonLogFormatter.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/util/log/XMLCocoonLogFormatter.java,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
--- XMLCocoonLogFormatter.java 2001/08/13 05:57:56 1.1.2.3
+++ XMLCocoonLogFormatter.java 2001/08/13 08:41:05 1.1.2.4
@@ -38,7 +38,6 @@
* element.</li>
* <li><code>uri</code> : outputs the request URI (<uri>).<li>
* <li><code>category</code> : outputs the log category (<category>).<li>
- * <li><code>context</code> : outputs the context (<context-stack>).<li>
* <li><code>message</code> : outputs the message (<message>).<li>
* <li><code>time</code> : outputs the time (<time>).<li>
* <li><code>rtime</code> : outputs the relative time (<relative-time>).<li>
@@ -49,7 +48,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
- * @version CVS $Revision: 1.1.2.3 $ $Date: 2001/08/13 05:57:56 $
+ * @version CVS $Revision: 1.1.2.4 $ $Date: 2001/08/13 08:41:05 $
*/
public class XMLCocoonLogFormatter
implements Formatter {
@@ -59,27 +58,25 @@
protected final static int TYPE_REQUEST_URI = 0;
protected final static int TYPE_CATEGORY = 1;
- protected final static int TYPE_CONTEXT = 2;
- protected final static int TYPE_MESSAGE = 3;
- protected final static int TYPE_TIME = 4;
- protected final static int TYPE_RELATIVE_TIME = 5;
- protected final static int TYPE_THROWABLE = 6;
- protected final static int TYPE_PRIORITY = 7;
- protected final static int TYPE_CLASS = 8;
- protected final static int TYPE_CLASS_SHORT = 9;
- protected final static int TYPE_THREAD = 10;
+ protected final static int TYPE_MESSAGE = 2;
+ protected final static int TYPE_TIME = 3;
+ protected final static int TYPE_RELATIVE_TIME = 4;
+ protected final static int TYPE_THROWABLE = 5;
+ protected final static int TYPE_PRIORITY = 6;
+ protected final static int TYPE_CLASS = 7;
+ protected final static int TYPE_CLASS_SHORT = 8;
+ protected final static int TYPE_THREAD = 9;
public final static String[] typeStrings = new String[] {"uri", // 0
"category", // 1
- "context", // 2
- "message", // 3
- "time", // 4
- "rtime", // 5
- "throwable", // 6
- "priority", // 7
- "class", // 8
- "class:short", // 9
- "thread"}; // 10
+ "message", // 2
+ "time", // 3
+ "rtime", // 4
+ "throwable", // 5
+ "priority", // 6
+ "class", // 7
+ "class:short", // 8
+ "thread"}; // 9
protected final static String EOL = System.getProperty("line.separator", "\n");
protected final SimpleDateFormat dateFormatter = new
SimpleDateFormat("(yyyy-MM-dd) HH:mm.ss:SSS");
@@ -101,7 +98,7 @@
case TYPE_REQUEST_URI:
sb.append("<uri>");
- sb.append(this.getURI(event.getContextStack()));
+ sb.append(this.getURI(event.getContextMap()));
sb.append("</uri>").append(EOL);
break;
@@ -118,7 +115,7 @@
case TYPE_THREAD:
sb.append("<thread>");
- sb.append(this.getThread(event.getContextStack()));
+ sb.append(this.getThread(event.getContextMap()));
sb.append("</thread>").append(EOL);
break;
@@ -158,20 +155,6 @@
sb.append(EOL).append("]]> </message>").append(EOL);
break;
- case TYPE_CONTEXT:
- sb.append("<context-stack>");
- final ContextStack stack = event.getContextStack();
- final int size = stack.getSize();
-
- for( int cs = 0; cs < size-1; cs++ ) {
- sb.append(stack.get( cs ));
- sb.append( '.' );
- }
-
- sb.append( stack.get( size-1 ) );
- sb.append("</context-stack>").append(EOL);
- break;
-
case TYPE_CATEGORY:
sb.append("<category>");
sb.append(event.getCategory());
@@ -193,14 +176,13 @@
/**
* Find the URI that is being processed.
*/
-
- private String getURI(ContextStack ctxStack) {
+ private String getURI(ContextMap ctxMap) {
String result = "Unknown-URI";
- // Get URI from the first context stack element, if it's a Map (the object
model).
- if (ctxStack.getSize() > 1) {
- Object context = ctxStack.get(1);
- if (context instanceof Map) {
+ // Get URI from the the object model.
+ if (ctxMap != null) {
+ Object context = ctxMap.get("objectModel");
+ if (context != null &&context instanceof Map) {
// Get the request
Request request =
(Request)((Map)context).get(Constants.REQUEST_OBJECT);
if (request != null) {
@@ -246,10 +228,9 @@
/**
* Find the thread that is logged this event.
*/
-
- private String getThread(ContextStack ctxStack) {
- if (ctxStack.getSize() > 0)
- return String.valueOf(ctxStack.get(0));
+ private String getThread(ContextMap ctxMap) {
+ if (ctxMap != null&& ctxMap.get("threadName") != null)
+ return (String)ctxMap.get("threadName");
else
return "Unknown-thread";
}
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]