net.sf.log4jdbc
Interface SpyLogDelegator

All Known Implementing Classes:
Log4JdbcCustomFormatter, Slf4jSpyLogDelegator

public interface SpyLogDelegator

Delegates Spy events to a logger. This interface is used for all logging activity used by log4jdbc and hides the specific implementation of any given logging system from log4jdbc.

Author:
Arthur Blake, Tim Azzopardi minor changes for supporting result set tracing

Method Summary
 void connectionClosed(Spy spy)
          Called whenever a connection spy is closed.
 void connectionOpened(Spy spy)
          Called whenever a new connection spy is created.
 void constructorReturned(Spy spy, String constructionInfo)
          Called when a spied upon object is constructed.
 void debug(String msg)
          Log a Setup and/or administrative log message for log4jdbc.
 void exceptionOccured(Spy spy, String methodCall, Exception e, String sql, long execTime)
          Called when a spied upon method throws an Exception.
 boolean isJdbcLoggingEnabled()
          Determine if any of the jdbc or sql loggers are turned on.
 boolean isResultSetCollectionEnabled()
          Determine whether the logger is expecting results sets to be collected
 boolean isResultSetCollectionEnabledWithUnreadValueFillIn()
          Determine whether the logger is expecting results sets to be collected AND any unread result set values read explicitly
 void methodReturned(Spy spy, String methodCall, Object returnValue, Object targetObject, Object... methodParams)
          Called when spied upon method call returns.
 void resultSetCollected(ResultSetCollector resultSetCollector)
          Called whenever result set has been collected
 String sqlOccured(Spy spy, String methodCall, String sql)
          Special call that is called only for JDBC method calls that contain SQL.
 String sqlOccured(Spy spy, String methodCall, String[] sqls)
          Special call that is called only for JDBC method calls that contain SQL batches.
 void sqlTimingOccured(Spy spy, long execTime, String methodCall, String sql)
          Similar to sqlOccured, but reported after SQL executes and used to report timing stats on the SQL
 

Method Detail

isJdbcLoggingEnabled

boolean isJdbcLoggingEnabled()
Determine if any of the jdbc or sql loggers are turned on.

Returns:
true if any of the jdbc or sql loggers are enabled at error level or higher.

exceptionOccured

void exceptionOccured(Spy spy,
                      String methodCall,
                      Exception e,
                      String sql,
                      long execTime)
Called when a spied upon method throws an Exception.

Parameters:
spy - the Spy wrapping the class that threw an Exception.
methodCall - a description of the name and call parameters of the method generated the Exception.
e - the Exception that was thrown.
sql - optional sql that occured just before the exception occured.
execTime - optional amount of time that passed before an exception was thrown when sql was being executed. caller should pass -1 if not used

methodReturned

void methodReturned(Spy spy,
                    String methodCall,
                    Object returnValue,
                    Object targetObject,
                    Object... methodParams)
Called when spied upon method call returns.

Parameters:
spy - the Spy wrapping the class that called the method that returned.
methodCall - a description of the name and call parameters of the method that returned.
returnValue - return value from the method call, null for void return types.
targetObject - the target object method call (E.g. a CallableStatement, ResultSet etc)
methodParams - the params passed to the method

constructorReturned

void constructorReturned(Spy spy,
                         String constructionInfo)
Called when a spied upon object is constructed.

Parameters:
spy - the Spy wrapping the class that called the method that returned.
constructionInfo - information about the object construction

sqlOccured

String sqlOccured(Spy spy,
                  String methodCall,
                  String sql)
Special call that is called only for JDBC method calls that contain SQL.

Parameters:
spy - the Spy wrapping the class where the SQL occured.
methodCall - a description of the name and call parameters of the method that generated the SQL.
sql - sql that occured.
Returns:
the (possibly reformatted) sql

sqlOccured

String sqlOccured(Spy spy,
                  String methodCall,
                  String[] sqls)
Special call that is called only for JDBC method calls that contain SQL batches.

Parameters:
spy - the Spy wrapping the class where the SQL occured.
methodCall - a description of the name and call parameters of the method that generated the SQL.
sqls - the sql batch that occured.
Returns:
the (possibly reformatted) sql string for the whole batch

sqlTimingOccured

void sqlTimingOccured(Spy spy,
                      long execTime,
                      String methodCall,
                      String sql)
Similar to sqlOccured, but reported after SQL executes and used to report timing stats on the SQL

Parameters:
spy - the Spy wrapping the class where the SQL occured.
execTime - how long it took the sql to run, in msec.
methodCall - a description of the name and call parameters of the method that generated the SQL.
sql - sql that occured.

connectionOpened

void connectionOpened(Spy spy)
Called whenever a new connection spy is created.

Parameters:
spy - ConnectionSpy that was created.

connectionClosed

void connectionClosed(Spy spy)
Called whenever a connection spy is closed.

Parameters:
spy - ConnectionSpy that was closed.

debug

void debug(String msg)
Log a Setup and/or administrative log message for log4jdbc.

Parameters:
msg - message to log.

isResultSetCollectionEnabled

boolean isResultSetCollectionEnabled()
Determine whether the logger is expecting results sets to be collected

Returns:
true if the logger is expecting results sets to be collected

isResultSetCollectionEnabledWithUnreadValueFillIn

boolean isResultSetCollectionEnabledWithUnreadValueFillIn()
Determine whether the logger is expecting results sets to be collected AND any unread result set values read explicitly

Returns:
true if the logger is expecting results sets to be collected

resultSetCollected

void resultSetCollected(ResultSetCollector resultSetCollector)
Called whenever result set has been collected



Copyright © 2012. All Rights Reserved.