refactor: simplify PlatformLog actuals and convert remaining interpolated log calls to lambdas

- Extract private log() helper in JVM and iOS PlatformLog to reduce
  copy-paste branching
- Fix JVM formatter to be private and non-nullable
- Convert 60+ interpolated Log.w/e/i calls to lambda overloads,
  including hot-path Filter.kt toJson() and LocalCache event processing

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
davotoula
2026-03-28 16:38:07 +01:00
parent 3b81731771
commit 6d89de9444
42 changed files with 107 additions and 130 deletions
@@ -23,51 +23,40 @@ package com.vitorpamplona.quartz.utils
import platform.Foundation.NSLog
actual object PlatformLog {
actual fun w(
private fun log(
level: String,
tag: String,
message: String,
throwable: Throwable?,
) {
if (throwable != null) {
NSLog("WARN: [$tag] $message. Throwable: $throwable CAUSE ${throwable.cause}")
NSLog("$level: [$tag] $message. Throwable: $throwable CAUSE ${throwable.cause}")
} else {
NSLog("WARN: [$tag] $message")
NSLog("$level: [$tag] $message")
}
}
actual fun w(
tag: String,
message: String,
throwable: Throwable?,
) = log("WARN", tag, message, throwable)
actual fun e(
tag: String,
message: String,
throwable: Throwable?,
) {
if (throwable != null) {
NSLog("ERROR: [$tag] $message. Throwable: $throwable CAUSE ${throwable.cause}")
} else {
NSLog("ERROR: [$tag] $message")
}
}
) = log("ERROR", tag, message, throwable)
actual fun d(
tag: String,
message: String,
throwable: Throwable?,
) {
if (throwable != null) {
NSLog("DEBUG: [$tag] $message. Throwable: $throwable CAUSE ${throwable.cause}")
} else {
NSLog("DEBUG: [$tag] $message")
}
}
) = log("DEBUG", tag, message, throwable)
actual fun i(
tag: String,
message: String,
throwable: Throwable?,
) {
if (throwable != null) {
NSLog("INFO: [$tag] $message. Throwable: $throwable CAUSE ${throwable.cause}")
} else {
NSLog("INFO: [$tag] $message")
}
}
) = log("INFO", tag, message, throwable)
}