org.skife.jdbi.v2.logging
Class FormattedLog

java.lang.Object
  extended by org.skife.jdbi.v2.logging.FormattedLog
All Implemented Interfaces:
SQLLog
Direct Known Subclasses:
Log4JLog, PrintStreamLog

public abstract class FormattedLog
extends Object
implements SQLLog

Convenience class which handles log statement formatting


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.skife.jdbi.v2.tweak.SQLLog
SQLLog.BatchLogger
 
Constructor Summary
FormattedLog()
           
 
Method Summary
protected abstract  boolean isEnabled()
          Used to ask implementations if logging is enabled.
protected abstract  void log(String msg)
          Log the statement passed in
 SQLLog.BatchLogger logBatch()
          Factory method used to obtain a SQLLog.BatchLogger which will be used to log a specific batch statement.
 void logBeginTransaction(Handle h)
          Called when a transaction is started
 void logCheckpointTransaction(Handle h, String name)
          Called when a transaction is checkpointed
 void logCommitTransaction(long time, Handle h)
          Called when a transaction is committed
 void logObtainHandle(long time, Handle h)
          Called when a handle is opened from a DBI instance
 void logPreparedBatch(long time, String sql, int count)
          Called to log a prepared batch execution
 void logReleaseCheckpointTransaction(Handle h, String name)
          Called when a transaction checkpoint is released
 void logReleaseHandle(Handle h)
          Called when a handle is closed
 void logRollbackToCheckpoint(long time, Handle h, String checkpointName)
          Called when a transaction checkpoint is rolled back to
 void logRollbackTransaction(long time, Handle h)
          Called when a transaction is committed
 void logSQL(long time, String sql)
          Called to log typical sql statements
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FormattedLog

public FormattedLog()
Method Detail

isEnabled

protected abstract boolean isEnabled()
Used to ask implementations if logging is enabled.

Returns:
true if statement logging is enabled

log

protected abstract void log(String msg)
Log the statement passed in

Parameters:
msg - the message to log

logBatch

public final SQLLog.BatchLogger logBatch()
Description copied from interface: SQLLog
Factory method used to obtain a SQLLog.BatchLogger which will be used to log a specific batch statement.

Specified by:
logBatch in interface SQLLog
Returns:
an instance of BatchLogger which will be used to log this batch

logBeginTransaction

public void logBeginTransaction(Handle h)
Description copied from interface: SQLLog
Called when a transaction is started

Specified by:
logBeginTransaction in interface SQLLog

logCheckpointTransaction

public void logCheckpointTransaction(Handle h,
                                     String name)
Description copied from interface: SQLLog
Called when a transaction is checkpointed

Specified by:
logCheckpointTransaction in interface SQLLog
name - the checkpoint name

logCommitTransaction

public void logCommitTransaction(long time,
                                 Handle h)
Description copied from interface: SQLLog
Called when a transaction is committed

Specified by:
logCommitTransaction in interface SQLLog

logObtainHandle

public void logObtainHandle(long time,
                            Handle h)
Description copied from interface: SQLLog
Called when a handle is opened from a DBI instance

Specified by:
logObtainHandle in interface SQLLog

logPreparedBatch

public final void logPreparedBatch(long time,
                                   String sql,
                                   int count)
Description copied from interface: SQLLog
Called to log a prepared batch execution

Specified by:
logPreparedBatch in interface SQLLog
sql - The sql for the prepared batch
count - the number of elements in the prepared batch

logReleaseCheckpointTransaction

public void logReleaseCheckpointTransaction(Handle h,
                                            String name)
Description copied from interface: SQLLog
Called when a transaction checkpoint is released

Specified by:
logReleaseCheckpointTransaction in interface SQLLog
name - the checkpoint name

logReleaseHandle

public void logReleaseHandle(Handle h)
Description copied from interface: SQLLog
Called when a handle is closed

Specified by:
logReleaseHandle in interface SQLLog

logRollbackToCheckpoint

public void logRollbackToCheckpoint(long time,
                                    Handle h,
                                    String checkpointName)
Description copied from interface: SQLLog
Called when a transaction checkpoint is rolled back to

Specified by:
logRollbackToCheckpoint in interface SQLLog

logRollbackTransaction

public void logRollbackTransaction(long time,
                                   Handle h)
Description copied from interface: SQLLog
Called when a transaction is committed

Specified by:
logRollbackTransaction in interface SQLLog

logSQL

public final void logSQL(long time,
                         String sql)
Description copied from interface: SQLLog
Called to log typical sql statements

Specified by:
logSQL in interface SQLLog
sql - the actual sql being exected


Copyright © 2011. All Rights Reserved.