Skip to content

Commit

Permalink
Include database name in transaction open/close logs
Browse files Browse the repository at this point in the history
  • Loading branch information
cedrickcooke committed Sep 5, 2024
1 parent a1b189b commit 58f36af
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions core/src/jsMain/kotlin/Database.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ public suspend fun openDatabase(
"Upgrading database `$name` from version `${versionChangeEvent.oldVersion}` to `${versionChangeEvent.newVersion}`"
}
val id = database.transactionId++
logger.log(Type.Transaction) { "Opened versionchange transaction $id" }
logger.log(Type.Transaction) { "Opened versionchange transaction $id on database `$name`" }
val transaction = VersionChangeTransaction(checkNotNull(request.transaction), logger, id)
transaction.initialize(database, versionChangeEvent.oldVersion, versionChangeEvent.newVersion)
transaction.awaitCompletion { event ->
logger.log(Type.Transaction, event) { "Closed versionchange transaction $id" }
logger.log(Type.Transaction, event) { "Closed versionchange transaction $id on database `$name`" }
}
}
logger.log(Type.Database) { "Opened database `$name`" }
Expand Down Expand Up @@ -115,10 +115,12 @@ public class Database internal constructor(
id,
)

logger.log(Type.Transaction) { "Opened readonly transaction $id using stores ${store.joinToString { "`$it`" }}" }
logger.log(Type.Transaction) {
"Opened readonly transaction $id using stores ${store.joinToString { "`$it`" }} on database `$name`"
}
val result = transaction.action()
transaction.awaitCompletion { event ->
logger.log(Type.Transaction, event) { "Closed readonly transaction $id" }
logger.log(Type.Transaction, event) { "Closed readonly transaction $id on database `$name`" }
}
result
}
Expand All @@ -145,10 +147,12 @@ public class Database internal constructor(
objectStore(store.first()).awaitTransaction()
}

logger.log(Type.Transaction) { "Opened readwrite transaction $id" }
logger.log(Type.Transaction) {
"Opened readwrite transaction $id using stores ${store.joinToString { "`$it`" }} on database `$name`"
}
val result = transaction.action()
transaction.awaitCompletion { event ->
logger.log(Type.Transaction, event) { "Closed readwrite transaction $id" }
logger.log(Type.Transaction, event) { "Closed readwrite transaction $id on database `$name`" }
}
result
}
Expand Down

0 comments on commit 58f36af

Please sign in to comment.