org.perf.log.filter.sql
Class SQLInterceptorSpyLogDelegator

java.lang.Object
  extended by org.perf.log.filter.sql.SQLInterceptorSpyLogDelegator
All Implemented Interfaces:
SpyLogDelegator

public class SQLInterceptorSpyLogDelegator
extends java.lang.Object
implements SpyLogDelegator

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

Author:
Arthur Blake Modified for custom class org.perf.log.SQLInterceptorSpyLogDelegator for capturing performance metrics and sending it to perf logger implementation, Pradeep Nambiar, Pexus LLC

Constructor Summary
SQLInterceptorSpyLogDelegator()
          Create a SpyLogDelegator specific to the Simple Logging Facade for Java (slf4j).
 
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, java.lang.String constructionInfo)
          Called when a spied upon object is constructed.
 void debug(java.lang.String msg)
          Log a Setup and/or administrative log message for log4jdbc.
 void exceptionOccured(Spy spy, java.lang.String methodCall, java.lang.Exception e, java.lang.String sql, long execTime)
          Called when a jdbc method throws an Exception.
 boolean isJdbcLoggingEnabled()
          Determine if any of the 5 log4jdbc spy loggers are turned on (jdbc.audit | jdbc.resultset | jdbc.sqlonly | jdbc.sqltiming | jdbc.connection)
 void methodReturned(Spy spy, java.lang.String methodCall, java.lang.String returnMsg)
          Called when a JDBC method from a Connection, Statement, PreparedStatement, CallableStatement or ResultSet returns.
 void sqlOccured(Spy spy, java.lang.String methodCall, java.lang.String sql)
          Special call that is called only for JDBC method calls that contain SQL.
 void sqlTimingOccured(Spy spy, long execTime, java.lang.String methodCall, java.lang.String sql)
          Special call that is called only for JDBC method calls that contain SQL.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SQLInterceptorSpyLogDelegator

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

Method Detail

isJdbcLoggingEnabled

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

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

exceptionOccured

public void exceptionOccured(Spy spy,
                             java.lang.String methodCall,
                             java.lang.Exception e,
                             java.lang.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,
                           java.lang.String methodCall,
                           java.lang.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,
                                java.lang.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,
                       java.lang.String methodCall,
                       java.lang.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,
                             java.lang.String methodCall,
                             java.lang.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(java.lang.String msg)
Log a Setup and/or administrative log message for log4jdbc.

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

connectionOpened

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

Specified by:
connectionOpened in interface SpyLogDelegator
Parameters:
spy - ConnectionSpy that was created.

connectionClosed

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

Specified by:
connectionClosed in interface SpyLogDelegator
Parameters:
spy - ConnectionSpy that was closed.