This is an automated email from the ASF dual-hosted git repository.
pjfanning pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko-persistence-jdbc.git
The following commit(s) were added to refs/heads/main by this push:
new 7b1f2b2d Defer debug log message construction to the logging backend
(#616)
7b1f2b2d is described below
commit 7b1f2b2d6985919d11c1853fd57be486364300e1
Author: PJ Fanning <[email protected]>
AuthorDate: Fri Sep 11 09:36:10 2026 +0100
Defer debug log message construction to the logging backend (#616)
Motivation:
Several debug calls built their message eagerly with string interpolation,
so
the interpolation (and, in JournalMigrator, a `mkString` over the tag set
for
every migrated event) ran even when debug logging was disabled.
Modification:
Replace interpolation with `{}` placeholders and pass the values as logging
arguments, and guard the JournalMigrator call — whose argument needs a
`mkString` — with `isDebugEnabled`.
Result:
No message or tag-set string is built unless the backend will emit the line.
Logging output is unchanged.
Tests:
- scalafmt on the three changed files/no reformatting needed
- No test added or run: the change only moves message formatting into the
logging backend and emits identical output; compilation and the existing
suites are covered by CI
References:
None - follow-up cleanup on the debug logging in these three files
---
.../pekko/persistence/jdbc/testkit/internal/SchemaUtilsImpl.scala | 4 ++--
.../org/apache/pekko/persistence/jdbc/migrator/JournalMigrator.scala | 5 ++++-
.../apache/pekko/persistence/jdbc/migrator/SnapshotMigrator.scala | 4 ++--
3 files changed, 8 insertions(+), 5 deletions(-)
diff --git
a/core/src/main/scala/org/apache/pekko/persistence/jdbc/testkit/internal/SchemaUtilsImpl.scala
b/core/src/main/scala/org/apache/pekko/persistence/jdbc/testkit/internal/SchemaUtilsImpl.scala
index 91fe9c90..23cd11ec 100644
---
a/core/src/main/scala/org/apache/pekko/persistence/jdbc/testkit/internal/SchemaUtilsImpl.scala
+++
b/core/src/main/scala/org/apache/pekko/persistence/jdbc/testkit/internal/SchemaUtilsImpl.scala
@@ -142,12 +142,12 @@ private[jdbc] object SchemaUtilsImpl {
for {
line <- lines if line.nonEmpty
} yield {
- logger.debug(s"applying DDL: $line")
+ logger.debug("applying DDL: {}", line)
try stmt.executeUpdate(line)
catch {
case t: java.sql.SQLException =>
- logger.debug(s"Exception while applying SQL script", t)
+ logger.debug("Exception while applying SQL script", t)
}
}
}
diff --git
a/migrator/src/main/scala/org/apache/pekko/persistence/jdbc/migrator/JournalMigrator.scala
b/migrator/src/main/scala/org/apache/pekko/persistence/jdbc/migrator/JournalMigrator.scala
index 5471adcf..7eee98f7 100644
---
a/migrator/src/main/scala/org/apache/pekko/persistence/jdbc/migrator/JournalMigrator.scala
+++
b/migrator/src/main/scala/org/apache/pekko/persistence/jdbc/migrator/JournalMigrator.scala
@@ -93,7 +93,10 @@ final case class JournalMigrator(profile:
JdbcProfile)(implicit system: ActorSys
val stmt: DBIO[Unit] = records
// get all the sql statements for this record as an option
.map { case (newRepr, newTags) =>
- log.debug(s"migrating event for PersistenceID:
${newRepr.persistenceId} with tags ${newTags.mkString(",")}")
+ if (log.isDebugEnabled()) {
+ log.debug("migrating event for PersistenceID: {} with tags {}",
newRepr.persistenceId,
+ newTags.mkString(","))
+ }
writeJournalRowsStatements(newRepr, newTags)
}
// reduce to 1 statement
diff --git
a/migrator/src/main/scala/org/apache/pekko/persistence/jdbc/migrator/SnapshotMigrator.scala
b/migrator/src/main/scala/org/apache/pekko/persistence/jdbc/migrator/SnapshotMigrator.scala
index 9444c08f..98c01225 100644
---
a/migrator/src/main/scala/org/apache/pekko/persistence/jdbc/migrator/SnapshotMigrator.scala
+++
b/migrator/src/main/scala/org/apache/pekko/persistence/jdbc/migrator/SnapshotMigrator.scala
@@ -79,7 +79,7 @@ case class SnapshotMigrator(profile: JdbcProfile)(implicit
system: ActorSystem)
// let us fetch the latest snapshot for each persistenceId
snapshotDB.run(queries.selectLatestByPersistenceId(persistenceId).result).map {
rows =>
rows.headOption.map(toSnapshotData).map { case (metadata, value) =>
- log.debug(s"migrating snapshot for ${metadata.toString}")
+ log.debug("migrating snapshot for {}", metadata)
defaultSnapshotDao.save(metadata, value)
}
}
@@ -94,7 +94,7 @@ case class SnapshotMigrator(profile: JdbcProfile)(implicit
system: ActorSystem)
.fromPublisher(snapshotDB.stream(queries.SnapshotTable.result))
.mapAsync(NoParallelism) { record =>
val (metadata, value) = toSnapshotData(record)
- log.debug(s"migrating snapshot for ${metadata.toString}")
+ log.debug("migrating snapshot for {}", metadata)
defaultSnapshotDao.save(metadata, value)
}
.run()
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]