Skip to content

Commit 6e30851

Browse files
committed
Improve logging in TransactionalTEL
This commit makes the logging in TransactionalTestExecutionListener consistent for both starting and ending transactions. Specifically, the current TestContext is now included in the informational log statement when starting a new transaction. Issue: SPR-11323
1 parent 96b418c commit 6e30851

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

spring-test/src/main/java/org/springframework/test/context/transaction/TransactionalTestExecutionListener.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,9 @@ private void startNewTransaction(TestContext testContext, TransactionContext txC
273273
txContext.startTransaction();
274274
++this.transactionsStarted;
275275
if (logger.isInfoEnabled()) {
276-
logger.info("Began transaction (" + this.transactionsStarted + "): transaction manager ["
277-
+ txContext.transactionManager + "]; rollback [" + isRollback(testContext) + "]");
276+
logger.info(String.format(
277+
"Began transaction (%s) for test context %s; transaction manager [%s]; rollback [%s]",
278+
this.transactionsStarted, testContext, txContext.transactionManager, isRollback(testContext)));
278279
}
279280
}
280281

@@ -288,8 +289,9 @@ private void startNewTransaction(TestContext testContext, TransactionContext txC
288289
private void endTransaction(TestContext testContext, TransactionContext txContext) throws Exception {
289290
boolean rollback = isRollback(testContext);
290291
if (logger.isTraceEnabled()) {
291-
logger.trace("Ending transaction for test context " + testContext + "; transaction manager ["
292-
+ txContext.transactionStatus + "]; rollback [" + rollback + "]");
292+
logger.trace(String.format(
293+
"Ending transaction for test context %s; transaction status [%s]; rollback [%s]", testContext,
294+
txContext.transactionStatus, rollback));
293295
}
294296
txContext.endTransaction(rollback);
295297
if (logger.isInfoEnabled()) {

0 commit comments

Comments
 (0)