org.abstracthorizon.danube.support.logging
Class AccessLogConnectionHandler

java.lang.Object
  extended by org.abstracthorizon.danube.support.logging.AccessLogConnectionHandler
All Implemented Interfaces:
ConnectionHandler
Direct Known Subclasses:
HTTPAccessLogConnectionHandler

public class AccessLogConnectionHandler
extends Object
implements ConnectionHandler

This handler implements simple access log.

If internally defines following pattern codes (through CurrentDateTimeProcessor, HandlingTimeProcessor and SocketDetailsProcessor):

Main aim was to keep as much compatibility with already known codes from Apache HTTP server

Author:
Daniel Sendula

Nested Class Summary
static class AccessLogConnectionHandler.DateWrapper
          Simple connection wrapper that adds handling started time in milliseconds
 
Field Summary
protected  int argumentNumber
          Number of arguments
protected  org.slf4j.Logger logger
          Logger
protected  String logPatternString
          Internal log pattern string
protected  PatternProcessor[] selectedProcessors
          Defined providers
 
Constructor Summary
AccessLogConnectionHandler()
          Constructor.
 
Method Summary
protected  void addPredefinedProcessors(List<String> providerClasses)
          Adds lists of predefined processors to the lists of provider classes.
protected  String createLogLine(Connection connection, long start)
          Creates log line.
 ConnectionHandler getConnectionHandler()
          Returns connection handler
 List<String> getCustomProcessors()
          Returns a list of custom processors' file names
protected  String getDefaultLogPattern()
          Returns default log pattern
 LogFileRotator getLogFileRotator()
          Returns log file rotator implementation
 String getLogPattern()
          Returns log pattern
 void handleConnection(Connection connection)
          Invokes supplied connectionHandler measuring time and then writes the log line
protected  void outputLogLine(String logLine)
          This method output log line to the log.
 void setConnectionHandler(ConnectionHandler connectionHandler)
          Sets connection handler
 void setCustomProcessors(List<String> customProcessors)
          Sets a list of custom processors' file names
 void setLogFileRotator(LogFileRotator logFileRotator)
          Sets log file rotator implementation
 void setLogPattern(String logPattern)
          Sets log pattern
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.slf4j.Logger logger
Logger


logPatternString

protected String logPatternString
Internal log pattern string


selectedProcessors

protected PatternProcessor[] selectedProcessors
Defined providers


argumentNumber

protected int argumentNumber
Number of arguments

Constructor Detail

AccessLogConnectionHandler

public AccessLogConnectionHandler()
Constructor. It sets log pattern to "%a %h %A %p %t %D %T"

Method Detail

getDefaultLogPattern

protected String getDefaultLogPattern()
Returns default log pattern

Returns:
default log pattern

getConnectionHandler

public ConnectionHandler getConnectionHandler()
Returns connection handler

Returns:
connection handler

setConnectionHandler

public void setConnectionHandler(ConnectionHandler connectionHandler)
Sets connection handler

Parameters:
connectionHandler - conneciton handler

getCustomProcessors

public List<String> getCustomProcessors()
Returns a list of custom processors' file names

Returns:
a list of custom processors' file names

setCustomProcessors

public void setCustomProcessors(List<String> customProcessors)
Sets a list of custom processors' file names

Parameters:
customProcessors - a list of custom processors' file names

getLogFileRotator

public LogFileRotator getLogFileRotator()
Returns log file rotator implementation

Returns:
log file rotator implementation

setLogFileRotator

public void setLogFileRotator(LogFileRotator logFileRotator)
Sets log file rotator implementation

Parameters:
logFileRotator - log file rotator implementation

getLogPattern

public String getLogPattern()
Returns log pattern

Returns:
log pattern

setLogPattern

public void setLogPattern(String logPattern)
Sets log pattern

Parameters:
logPattern - log pattern

addPredefinedProcessors

protected void addPredefinedProcessors(List<String> providerClasses)

Adds lists of predefined processors to the lists of provider classes.

This method adds following:

Parameters:
providerClasses - list of provider classes

handleConnection

public void handleConnection(Connection connection)
Invokes supplied connectionHandler measuring time and then writes the log line

Specified by:
handleConnection in interface ConnectionHandler
Parameters:
connection - connection

outputLogLine

protected void outputLogLine(String logLine)
This method output log line to the log.

Parameters:
logLine - log line

createLogLine

protected String createLogLine(Connection connection,
                               long start)
Creates log line. This method can be overriden to prevent log from happening by returning null.

Parameters:
connection - connection
start - start time
Returns:
log line or null for nothing to be logged


Copyright © 2005-2009 Abstract Horizon. All Rights Reserved.