Return-Path: Delivered-To: apmail-incubator-sling-commits-archive@locus.apache.org Received: (qmail 4813 invoked from network); 8 May 2008 13:33:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 8 May 2008 13:33:56 -0000 Received: (qmail 24477 invoked by uid 500); 8 May 2008 13:33:58 -0000 Delivered-To: apmail-incubator-sling-commits-archive@incubator.apache.org Received: (qmail 24450 invoked by uid 500); 8 May 2008 13:33:58 -0000 Mailing-List: contact sling-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: sling-dev@incubator.apache.org Delivered-To: mailing list sling-commits@incubator.apache.org Received: (qmail 24441 invoked by uid 99); 8 May 2008 13:33:58 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 May 2008 06:33:58 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 May 2008 13:33:21 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id D47772388A1B; Thu, 8 May 2008 06:33:35 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r654519 - in /incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/debug: ./ RequestProgressTrackerLogFilter.java Date: Thu, 08 May 2008 13:33:35 -0000 To: sling-commits@incubator.apache.org From: bdelacretaz@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080508133335.D47772388A1B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: bdelacretaz Date: Thu May 8 06:33:35 2008 New Revision: 654519 URL: http://svn.apache.org/viewvc?rev=654519&view=rev Log: SLING-3 - RequestProgressTrackerLogFilter logs RequestProgressTracker info at the DEBUG level Added: incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/debug/ incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/debug/RequestProgressTrackerLogFilter.java (with props) Added: incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/debug/RequestProgressTrackerLogFilter.java URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/debug/RequestProgressTrackerLogFilter.java?rev=654519&view=auto ============================================================================== --- incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/debug/RequestProgressTrackerLogFilter.java (added) +++ incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/debug/RequestProgressTrackerLogFilter.java Thu May 8 06:33:35 2008 @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.sling.core.impl.debug; + +import java.io.IOException; +import java.util.Iterator; + +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; + +import org.apache.sling.api.SlingHttpServletRequest; +import org.apache.sling.api.request.RequestProgressTracker; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** Filter that dumps the output of the RequestProgressTracker to the log + * after processing the request. + * + * @scr.component immediate="true" metatype="false" + * @scr.property name="service.description" value="RequestProgressTracker dump filter" + * @scr.property name="service.vendor" value="The Apache Software Foundation" + * @scr.property name="filter.scope" value="request" private="true" + * @scr.service + */ +public class RequestProgressTrackerLogFilter implements Filter { + + private static final Logger log = LoggerFactory.getLogger(RequestProgressTrackerLogFilter.class); + private int requestCounter; + + public void init(FilterConfig filterConfig) throws ServletException { + } + + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException { + + chain.doFilter(request, response); + + if(log.isDebugEnabled() && request instanceof SlingHttpServletRequest) { + int requestId = 0; + synchronized (getClass()) { + requestId = ++requestCounter; + } + final RequestProgressTracker t = ((SlingHttpServletRequest)request).getRequestProgressTracker(); + final Iterator it = t.getMessages(); + while(it.hasNext()) { + log.debug("REQUEST_{} - " + it.next(), requestId); + } + } + } + + public void destroy() { + } + +} \ No newline at end of file Propchange: incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/debug/RequestProgressTrackerLogFilter.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/debug/RequestProgressTrackerLogFilter.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Rev URL