public class Slf4jSpyLogDelegator extends Object implements SpyLogDelegator
Modifications for log4j2:
connectionOpened(Spy)
into
connectionOpened(Spy, long)
, to accept a parameter execTime
,
defining the time elapsed to open the connection in ms. This new method simply delegates
to the formerly existing method, now private, so that the behavior of the slf4j logger is not modified.
See SpyLogDelegator
for more details.
connectionClosed(Spy)
into
connectionClosed(Spy, long)
, to accept a parameter execTime
,
defining the time elapsed to open the connection in ms. This new method simply delegates
to the formerly existing method, now private, so that the behavior of the slf4j logger is not modified.
See SpyLogDelegator
for more details.
Constructor and Description |
---|
Slf4jSpyLogDelegator()
Create a SpyLogDelegator specific to the Simple Logging Facade for Java (slf4j).
|
Modifier and Type | Method and Description |
---|---|
void |
connectionAborted(Spy spy,
long execTime)
Called whenever a connection spy is aborted.
|
void |
connectionClosed(Spy spy,
long execTime)
Called whenever a connection spy is closed.
|
void |
connectionOpened(Spy spy,
long execTime)
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 5 log4jdbc spy loggers are turned on (jdbc.audit | jdbc.resultset |
jdbc.sqlonly | jdbc.sqltiming | jdbc.connection)
|
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,
String returnMsg)
Called when spied upon method call returns.
|
void |
resultSetCollected(ResultSetCollector resultSetCollector)
Called whenever result set has been collected.
|
void |
sqlOccurred(Spy spy,
String methodCall,
String sql)
Special call that is called only for JDBC method calls that contain SQL.
|
void |
sqlTimingOccurred(Spy spy,
long execTime,
String methodCall,
String sql)
Special call that is called only for JDBC method calls that contain SQL.
|
public Slf4jSpyLogDelegator()
public boolean isJdbcLoggingEnabled()
isJdbcLoggingEnabled
in interface SpyLogDelegator
public void exceptionOccured(Spy spy, String methodCall, Exception e, String sql, long execTime)
SpyLogDelegator
exceptionOccured
in interface SpyLogDelegator
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 usedpublic void methodReturned(Spy spy, String methodCall, String returnMsg)
SpyLogDelegator
methodReturned
in interface SpyLogDelegator
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.public void constructorReturned(Spy spy, String constructionInfo)
SpyLogDelegator
constructorReturned
in interface SpyLogDelegator
spy
- the Spy wrapping the class that called the method that returned.constructionInfo
- information about the object constructionpublic void sqlOccurred(Spy spy, String methodCall, String sql)
SpyLogDelegator
sqlOccurred
in interface SpyLogDelegator
spy
- the Spy wrapping the class where the SQL occurred.methodCall
- a description of the name and call parameters of the method that generated the SQL.sql
- sql that occurred.public void sqlTimingOccurred(Spy spy, long execTime, String methodCall, String sql)
sqlTimingOccurred
in interface SpyLogDelegator
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.public void debug(String msg)
SpyLogDelegator
debug
in interface SpyLogDelegator
msg
- message to log.public void connectionOpened(Spy spy, long execTime)
SpyLogDelegator
connectionOpened
in interface SpyLogDelegator
spy
- ConnectionSpy that was created.execTime
- A long
defining the time elapsed to open the connection in ms
(useful information, as a connection might take some time to be opened sometimes).
Caller should pass -1 if not used or unknown.public void connectionClosed(Spy spy, long execTime)
SpyLogDelegator
connectionClosed
in interface SpyLogDelegator
spy
- ConnectionSpy
that was closed.execTime
- A long
defining the time elapsed to close the connection in ms
(useful information, as a connection might take some time to be closed sometimes).
Caller should pass -1 if not used or unknown.public void connectionAborted(Spy spy, long execTime)
SpyLogDelegator
connectionAborted
in interface SpyLogDelegator
spy
- ConnectionSpy
that was aborted.execTime
- A long
defining the time elapsed to abort the connection in ms
(useful information, as a connection might take some time to be aborted sometimes).
Caller should pass -1 if not used or unknown.public boolean isResultSetCollectionEnabled()
SpyLogDelegator
isResultSetCollectionEnabled
in interface SpyLogDelegator
public boolean isResultSetCollectionEnabledWithUnreadValueFillIn()
SpyLogDelegator
isResultSetCollectionEnabledWithUnreadValueFillIn
in interface SpyLogDelegator
public void resultSetCollected(ResultSetCollector resultSetCollector)
SpyLogDelegator
next()
method of the spied ResultSet
return false
meaning that its end is reached.
It will be also called if the ResultSet
is closed.resultSetCollected
in interface SpyLogDelegator
net.sf.log4jdbc.ResultSetSpy
,
DefaultResultSetCollector
Copyright © 2013 Bgee - Swiss Institute of Bioinformatics. All Rights Reserved.