Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

* Add `PowerSyncDatabase.getCrudTransactions()`, returning a flow of transactions. This is useful
to upload multiple transactions in a batch.
* Fix modifying severity of the global Kermit logger
* Add `PowerSync` tag for the logs

## 1.4.0

Expand Down
34 changes: 19 additions & 15 deletions core/src/commonMain/kotlin/com/powersync/utils/Log.kt
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
package com.powersync.utils

import BuildConfig
import co.touchlab.kermit.Logger
import co.touchlab.kermit.Severity
import co.touchlab.kermit.StaticConfig
import co.touchlab.kermit.platformLogWriter

/*
* Generates a logger with the appropriate severity level based on the build type
* if no Logger is provided.
*/
public fun generateLogger(logger: Logger?): Logger {
if (logger != null) {
return logger
}

val defaultLogger: Logger = Logger

if (BuildConfig.isDebug) {
Logger.setMinSeverity(Severity.Verbose)
} else {
Logger.setMinSeverity(Severity.Warn)
}

return defaultLogger
}
public fun generateLogger(logger: Logger?): Logger =
logger
?: Logger(
config =
StaticConfig(
logWriterList =
listOf(platformLogWriter()),
minSeverity =
if (BuildConfig.isDebug) {
Severity.Verbose
} else {
Severity.Warn
},
),
tag = "PowerSync",
)
Loading