Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Yet more logging

  • Loading branch information...
commit cef374f5b1fb8f9faacea167f3811d57d395682d 1 parent b52f99d
@brianm brianm authored
View
5 RELEASE_NOTES
@@ -1,3 +1,8 @@
+2.1.0
+ Add Query#fold
+
+ Add additional logging around handles and transactions
+
2.0.2
Clean up a NullPointerException which was masking an
UnableToCreateStatementException
View
12 src/java/org/skife/jdbi/v2/BasicHandle.java
@@ -104,7 +104,7 @@ public void define(String key, Object value)
public Handle begin()
{
transactions.begin(this);
- log.logBeginTransaction();
+ log.logBeginTransaction(this);
return this;
}
@@ -114,7 +114,7 @@ public Handle begin()
public Handle commit()
{
transactions.commit(this);
- log.logCommitTransaction();
+ log.logCommitTransaction(this);
return this;
}
@@ -124,7 +124,7 @@ public Handle commit()
public Handle rollback()
{
transactions.rollback(this);
- log.logRollbackTransaction();
+ log.logRollbackTransaction(this);
return this;
}
@@ -137,7 +137,7 @@ public Handle rollback()
public Handle checkpoint(String name)
{
transactions.checkpoint(this, name);
- log.logCheckpointTransaction(name);
+ log.logCheckpointTransaction(this, name);
return this;
}
@@ -148,7 +148,7 @@ public Handle checkpoint(String name)
public Handle release(String checkpointName)
{
transactions.release(this, checkpointName);
- log.logReleaseCheckpointTransaction(checkpointName);
+ log.logReleaseCheckpointTransaction(this, checkpointName);
return this;
}
@@ -170,7 +170,7 @@ public void setSQLLog(SQLLog log)
public Handle rollback(String checkpointName)
{
transactions.rollback(this, checkpointName);
- log.logRollbackToCheckpoint(checkpointName);
+ log.logRollbackToCheckpoint(this, checkpointName);
return this;
}
View
24 src/java/org/skife/jdbi/v2/logging/FormattedLog.java
@@ -62,19 +62,19 @@ public final void log()
}
}
- public void logBeginTransaction()
+ public void logBeginTransaction(Handle h)
{
- log("begin transaction");
+ if (isEnabled()) log(String.format("begin transaction on [%s]", h));
}
- public void logCommitTransaction()
+ public void logCommitTransaction(Handle h)
{
- log("commit transaction");
+ if (isEnabled()) log(String.format("commit transaction on [%s]", h));
}
- public void logRollbackTransaction()
+ public void logRollbackTransaction(Handle h)
{
- log("rollback transaction");
+ if (isEnabled()) log(String.format("rollback transaction on [%s]", h));
}
public void logObtainHandle(Handle h)
@@ -91,24 +91,24 @@ public void logReleaseHandle(Handle h)
}
}
- public void logCheckpointTransaction(String name)
+ public void logCheckpointTransaction(Handle h, String name)
{
if (this.isEnabled()) {
- log(String.format("checkpoint [%s] created", name));
+ log(String.format("checkpoint [%s] created on [%s]", name, h));
}
}
- public void logReleaseCheckpointTransaction(String name)
+ public void logReleaseCheckpointTransaction(Handle h, String name)
{
if (this.isEnabled()) {
- log(String.format("checkpoint [%s] released", name));
+ log(String.format("checkpoint [%s] on [%s] released", name, h));
}
}
- public void logRollbackToCheckpoint(String checkpointName)
+ public void logRollbackToCheckpoint(Handle h, String checkpointName)
{
if (this.isEnabled()) {
- log(String.format("checkpoint [%s] rolled back", checkpointName));
+ log(String.format("checkpoint [%s] on [%s] rolled back", checkpointName, h));
}
}
}
View
43 src/java/org/skife/jdbi/v2/logging/NoOpLog.java
@@ -8,15 +8,27 @@
*/
public final class NoOpLog implements SQLLog
{
- public void logBeginTransaction()
+
+ final static BatchLogger batch = new BatchLogger() {
+
+ public final void add(String sql)
+ {
+ }
+
+ public final void log()
+ {
+ }
+ };
+
+ public void logBeginTransaction(Handle h)
{
}
- public void logCommitTransaction()
+ public void logCommitTransaction(Handle h)
{
}
- public void logRollbackTransaction()
+ public void logRollbackTransaction(Handle h)
{
}
@@ -28,39 +40,28 @@ public void logReleaseHandle(Handle h)
{
}
- public final void logSQL(String sql)
+ public void logSQL(String sql)
{
}
- public final void logPreparedBatch(String sql, int count)
+ public void logPreparedBatch(String sql, int count)
{
}
- public final BatchLogger logBatch()
+ public BatchLogger logBatch()
{
- return batch;
+ return null;
}
- public void logCheckpointTransaction(String name)
+ public void logCheckpointTransaction(Handle h, String name)
{
}
- public void logReleaseCheckpointTransaction(String name)
+ public void logReleaseCheckpointTransaction(Handle h, String name)
{
}
- public void logRollbackToCheckpoint(String checkpointName)
+ public void logRollbackToCheckpoint(Handle h, String checkpointName)
{
}
-
- final static BatchLogger batch = new BatchLogger() {
-
- public final void add(String sql)
- {
- }
-
- public final void log()
- {
- }
- };
}
View
12 src/java/org/skife/jdbi/v2/tweak/SQLLog.java
@@ -10,17 +10,17 @@
/**
* Called when a transaction is started
*/
- public void logBeginTransaction();
+ public void logBeginTransaction(Handle h);
/**
* Called when a transaction is committed
*/
- public void logCommitTransaction();
+ public void logCommitTransaction(Handle h);
/**
* Called when a transaction is committed
*/
- public void logRollbackTransaction();
+ public void logRollbackTransaction(Handle h);
/**
* Called when a handle is opened from a DBI instance
@@ -57,19 +57,19 @@
* Called when a transaction is checkpointed
* @param name the checkpoint name
*/
- void logCheckpointTransaction(String name);
+ void logCheckpointTransaction(Handle h, String name);
/**
* Called when a transaction checkpoint is released
* @param name the checkpoint name
*/
- void logReleaseCheckpointTransaction(String name);
+ void logReleaseCheckpointTransaction(Handle h, String name);
/**
* Called when a transaction checkpoint is rolled back to
* @param name the checkpoint name
*/
- void logRollbackToCheckpoint(String checkpointName);
+ void logRollbackToCheckpoint(Handle h, String checkpointName);
/**
* Instances of this are used to log batch statements. SQLLog#logBatch will return one of these.
View
12 src/test/org/skife/jdbi/v2/TestSqlLogging.java
@@ -32,17 +32,17 @@ public void setUp() throws Exception
logged = new ArrayList<String>();
log = new SQLLog()
{
- public void logBeginTransaction()
+ public void logBeginTransaction(Handle h)
{
logged.add("begin");
}
- public void logCommitTransaction()
+ public void logCommitTransaction(Handle h)
{
logged.add("commit");
}
- public void logRollbackTransaction()
+ public void logRollbackTransaction(Handle h)
{
logged.add("rollback");
}
@@ -83,17 +83,17 @@ public void log()
};
}
- public void logCheckpointTransaction(String name)
+ public void logCheckpointTransaction(Handle h, String name)
{
logged.add(String.format("checkpoint %s created", name));
}
- public void logReleaseCheckpointTransaction(String name)
+ public void logReleaseCheckpointTransaction(Handle h, String name)
{
logged.add(String.format("checkpoint %s released", name));
}
- public void logRollbackToCheckpoint(String name)
+ public void logRollbackToCheckpoint(Handle h, String name)
{
logged.add(String.format("checkpoint %s rolled back to", name));
}
Please sign in to comment.
Something went wrong with that request. Please try again.