log4jdbc4 1.1

net.sf.log4jdbc
Class Slf4jSpyLogDelegator

java.lang.Object
  extended by net.sf.log4jdbc.Slf4jSpyLogDelegator
All Implemented Interfaces:
SpyLogDelegator

public class Slf4jSpyLogDelegator
extends Object
implements SpyLogDelegator

Delegates JDBC spy logging events to the the Simple Logging Facade for Java (slf4j).

Author:
Arthur Blake
 

Constructor Summary
Slf4jSpyLogDelegator()
          Create a SpyLogDelegator specific to the Simple Logging Facade for Java (slf4j).
 
Method Summary
 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 jdbc method throws an Exception.
 boolean isJdbcLoggingEnabled()
          Determine if any of the 4 log4jdbc spy loggers are turned on (jdbc.audit | jdbc.resultset | jdbc.sqlonly | jdbc.sqltiming.)
 void methodReturned(Spy spy, String methodCall, String returnMsg)
          Called when a jdbc method from a Connection, Statement, PreparedStatement, CallableStatement or ResultSet returns.
 void sqlOccured(Spy spy, String methodCall, String sql)
          Special call that is called only for JDBC method calls that contain SQL.
 void sqlTimingOccured(Spy spy, long execTime, String methodCall, String sql)
          Special call that is called only for JDBC method calls that contain SQL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Slf4jSpyLogDelegator

public Slf4jSpyLogDelegator()
Create a SpyLogDelegator specific to the Simple Logging Facade for Java (slf4j).

Method Detail

isJdbcLoggingEnabled

public boolean isJdbcLoggingEnabled()
Determine if any of the 4 log4jdbc spy loggers are turned on (jdbc.audit | jdbc.resultset | jdbc.sqlonly | jdbc.sqltiming.)

Specified by:
isJdbcLoggingEnabled in interface SpyLogDelegator
Returns:
true if any of the 4 spy jdbc/sql loggers are enabled at debug info or error level.

exceptionOccured

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

Specified by:
exceptionOccured in interface SpyLogDelegator
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

public void methodReturned(Spy spy,
                           String methodCall,
                           String returnMsg)
Called when a jdbc method from a Connection, Statement, PreparedStatement, CallableStatement or ResultSet returns.

Specified by:
methodReturned in interface SpyLogDelegator
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.
returnMsg - return value converted to a String for integral types, or String representation for Object return types this will be null for void return types.

constructorReturned

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

Specified by:
constructorReturned in interface SpyLogDelegator
Parameters:
spy - the Spy wrapping the class that called the method that returned.
constructionInfo - information about the object construction

sqlOccured

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

Specified by:
sqlOccured in interface SpyLogDelegator
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.

sqlTimingOccured

public void sqlTimingOccured(Spy spy,
                             long execTime,
                             String methodCall,
                             String sql)
Special call that is called only for JDBC method calls that contain SQL.

Specified by:
sqlTimingOccured in interface SpyLogDelegator
Parameters:
spy - the Spy wrapping the class where the SQL occurred.
execTime - how long it took the SQL to run, in milliseconds.
methodCall - a description of the name and call parameters of the method that generated the SQL.
sql - SQL that occurred.

debug

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

Specified by:
debug in interface SpyLogDelegator
Parameters:
msg - message to log.

log4jdbc4 1.1