com.noelios.restlet
Class LogFilter

java.lang.Object
  extended by org.restlet.Uniform
      extended by org.restlet.Restlet
          extended by org.restlet.Filter
              extended by com.noelios.restlet.LogFilter

public class LogFilter
extends Filter

Filter logging all calls after their handling by the target Restlet. The current format is similar to IIS 6 logs. The logging is based on the java.util.logging package. Concurrency note: instances of this class or its subclasses can be invoked by several threads at the same time and therefore must be thread-safe. You should be especially careful when storing state in member variables.

Author:
Jerome Louvel
See Also:
Tutorial : Filters and call logging

Field Summary
protected  LogService logService
          The log service.
protected  Template logTemplate
          The log template to use.
 
Fields inherited from class org.restlet.Filter
CONTINUE, SKIP, STOP
 
Constructor Summary
LogFilter(Context context, LogService logService)
          Constructor.
 
Method Summary
protected  void afterHandle(Request request, Response response)
          Allows filtering after processing by the next Restlet.
protected  int beforeHandle(Request request, Response response)
          Allows filtering before processing by the next Restlet.
protected  java.lang.String format(Request request, Response response)
          Format a log entry.
protected  java.lang.String formatDefault(Request request, Response response, int duration)
          Format a log entry using the default format.
 
Methods inherited from class org.restlet.Filter
doHandle, getNext, handle, hasNext, setNext, setNext
 
Methods inherited from class org.restlet.Restlet
getApplication, getContext, getLogger, init, isStarted, isStopped, setContext, start, stop
 
Methods inherited from class org.restlet.Uniform
delete, delete, get, get, handle, head, head, options, options, post, post, put, put
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logService

protected volatile LogService logService
The log service.


logTemplate

protected volatile Template logTemplate
The log template to use.

Constructor Detail

LogFilter

public LogFilter(Context context,
                 LogService logService)
Constructor.

Parameters:
context - The context.
logService - The log service descriptor.
Method Detail

afterHandle

protected void afterHandle(Request request,
                           Response response)
Allows filtering after processing by the next Restlet. Logs the call.

Overrides:
afterHandle in class Filter
Parameters:
request - The request to handle.
response - The response to update.

beforeHandle

protected int beforeHandle(Request request,
                           Response response)
Allows filtering before processing by the next Restlet. Saves the start time.

Overrides:
beforeHandle in class Filter
Parameters:
request - The request to handle.
response - The response to update.
Returns:
The continuation status.

format

protected java.lang.String format(Request request,
                                  Response response)
Format a log entry.

Parameters:
request - The request to log.
response - The response to log.
Returns:
The formatted log entry.

formatDefault

protected java.lang.String formatDefault(Request request,
                                         Response response,
                                         int duration)
Format a log entry using the default format.

Parameters:
request - The request to log.
response - The response to log.
duration - The call duration (in milliseconds).
Returns:
The formatted log entry.


Copyright © 2005-2008 Noelios Technologies.