perf: convert 194 interpolated Log.d() calls to lambda overloads

Defers string construction until after the level check, avoiding
allocation when debug logging is filtered in release/benchmark builds.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
davotoula
2026-03-28 16:21:39 +01:00
parent 541b197a64
commit 3b81731771
78 changed files with 205 additions and 214 deletions
@@ -46,7 +46,7 @@ object PushDistributorHandler : PushDistributorActions {
fun setEndpoint(newEndpoint: String) {
endpointInternal = newEndpoint
Log.d("PushHandler", "New endpoint saved : $endpointInternal")
Log.d("PushHandler") { "New endpoint saved : $endpointInternal" }
}
fun removeEndpoint() {
@@ -53,7 +53,7 @@ class PushMessageReceiver : MessagingReceiver() {
instance: String,
) {
val messageStr = message.content.decodeToString()
Log.d(TAG, "New message $messageStr for Instance: $instance")
Log.d(TAG) { "New message $messageStr for Instance: $instance" }
scope.launch {
try {
parseMessage(messageStr)?.let {
@@ -61,7 +61,7 @@ class PushMessageReceiver : MessagingReceiver() {
}
} catch (e: Exception) {
if (e is CancellationException) throw e
Log.d(TAG, "Message could not be parsed: ${e.message}")
Log.d(TAG) { "Message could not be parsed: ${e.message}" }
}
}
}
@@ -87,7 +87,7 @@ class PushMessageReceiver : MessagingReceiver() {
) {
val sanitizedEndpoint = if (endpoint.url.endsWith("?up=1")) endpoint.url.dropLast(5) else endpoint.url
if (sanitizedEndpoint != pushHandler.getSavedEndpoint()) {
Log.d(TAG, "New endpoint provided:- $endpoint for Instance: $instance ${pushHandler.getSavedEndpoint()} $sanitizedEndpoint")
Log.d(TAG) { "New endpoint provided:- $endpoint for Instance: $instance ${pushHandler.getSavedEndpoint()} $sanitizedEndpoint" }
pushHandler.setEndpoint(sanitizedEndpoint)
scope.launch(Dispatchers.IO) {
PushNotificationUtils.checkAndInit(sanitizedEndpoint, LocalPreferences.allSavedAccounts()) {
@@ -97,7 +97,7 @@ class PushMessageReceiver : MessagingReceiver() {
NotificationUtils.getOrCreateDMChannel(appContext)
}
} else {
Log.d(TAG, "Same endpoint provided:- $endpoint for Instance: $instance $sanitizedEndpoint")
Log.d(TAG) { "Same endpoint provided:- $endpoint for Instance: $instance $sanitizedEndpoint" }
}
}
@@ -106,7 +106,7 @@ class PushMessageReceiver : MessagingReceiver() {
reason: FailedReason,
instance: String,
) {
Log.d(TAG, "Registration failed for Instance: $instance")
Log.d(TAG) { "Registration failed for Instance: $instance" }
pushHandler.forceRemoveDistributor(context)
}
@@ -115,7 +115,7 @@ class PushMessageReceiver : MessagingReceiver() {
instance: String,
) {
val removedEndpoint = pushHandler.getSavedEndpoint()
Log.d(TAG, "Endpoint: $removedEndpoint removed for Instance: $instance")
Log.d(TAG) { "Endpoint: $removedEndpoint removed for Instance: $instance" }
Log.d(TAG, "App is unregistered. ")
pushHandler.forceRemoveDistributor(context)
pushHandler.removeEndpoint()
@@ -28,7 +28,7 @@ import com.vitorpamplona.quartz.utils.LogLevel
class Amethyst : Application() {
init {
Log.minLevel = if (BuildConfig.DEBUG) LogLevel.DEBUG else LogLevel.ERROR
Log.d("AmethystApp", "Creating App $this")
Log.d("AmethystApp") { "Creating App $this" }
}
companion object {
@@ -38,7 +38,7 @@ class Amethyst : Application() {
override fun onCreate() {
super.onCreate()
Log.d("AmethystApp", "onCreate $this")
Log.d("AmethystApp") { "onCreate $this" }
instance = AppModules(this)
if (isDebug) {
@@ -50,7 +50,7 @@ class Amethyst : Application() {
override fun onTerminate() {
super.onTerminate()
Log.d("AmethystApp", "onTerminate $this")
Log.d("AmethystApp") { "onTerminate $this" }
instance.terminate(this)
}
@@ -61,7 +61,7 @@ class Amethyst : Application() {
*/
override fun onTrimMemory(level: Int) {
super.onTrimMemory(level)
Log.d("AmethystApp", "onTrimMemory $level")
Log.d("AmethystApp") { "onTrimMemory $level" }
instance.trim()
}
}
@@ -46,19 +46,19 @@ fun debugState(context: Context) {
val jvmHeapAllocatedMb = totalMemoryMb - freeMemoryMb
Log.d(STATE_DUMP_TAG, "Total Heap Allocated: $jvmHeapAllocatedMb/$maxMemoryMb MB")
Log.d(STATE_DUMP_TAG) { "Total Heap Allocated: $jvmHeapAllocatedMb/$maxMemoryMb MB" }
val nativeHeap = Debug.getNativeHeapAllocatedSize() / (1024 * 1024)
val maxNative = Debug.getNativeHeapSize() / (1024 * 1024)
Log.d(STATE_DUMP_TAG, "Total Native Heap Allocated: $nativeHeap/$maxNative MB")
Log.d(STATE_DUMP_TAG) { "Total Native Heap Allocated: $nativeHeap/$maxNative MB" }
val activityManager: ActivityManager? = context.getSystemService()
if (activityManager != null) {
val isLargeHeap = (context.applicationInfo.flags and ApplicationInfo.FLAG_LARGE_HEAP) != 0
val memClass = if (isLargeHeap) activityManager.largeMemoryClass else activityManager.memoryClass
Log.d(STATE_DUMP_TAG, "Memory Class $memClass MB (largeHeap $isLargeHeap)")
Log.d(STATE_DUMP_TAG) { "Memory Class $memClass MB (largeHeap $isLargeHeap)" }
}
Log.d(
@@ -68,14 +68,8 @@ fun debugState(context: Context) {
.size() + "/" + normalizedUrls.size(),
)
Log.d(
STATE_DUMP_TAG,
"Image Disk Cache ${(Amethyst.instance.diskCache.size) / (1024 * 1024)}/${(Amethyst.instance.diskCache.maxSize) / (1024 * 1024)} MB",
)
Log.d(
STATE_DUMP_TAG,
"Image Memory Cache ${(Amethyst.instance.memoryCache.size) / (1024 * 1024)}/${(Amethyst.instance.memoryCache.maxSize) / (1024 * 1024)} MB",
)
Log.d(STATE_DUMP_TAG) { "Image Disk Cache ${(Amethyst.instance.diskCache.size) / (1024 * 1024)}/${(Amethyst.instance.diskCache.maxSize) / (1024 * 1024)} MB" }
Log.d(STATE_DUMP_TAG) { "Image Memory Cache ${(Amethyst.instance.memoryCache.size) / (1024 * 1024)}/${(Amethyst.instance.memoryCache.maxSize) / (1024 * 1024)} MB" }
Log.d(
STATE_DUMP_TAG,
@@ -130,13 +124,12 @@ fun debugState(context: Context) {
LocalCache.ephemeralChannels.values().sumOf { it.notes.size() },
)
LocalCache.chatroomList.forEach { key, room ->
Log.d(
STATE_DUMP_TAG,
Log.d(STATE_DUMP_TAG) {
"Private Chats $key: " +
room.rooms.size() +
" / " +
room.rooms.sumOf { key, value -> value.messages.size },
)
room.rooms.sumOf { key, value -> value.messages.size }
}
}
Log.d(
STATE_DUMP_TAG,
@@ -173,10 +166,10 @@ fun debugState(context: Context) {
.sumByGroup(groupMap = { _, it -> it.event?.kind }, sumOf = { _, it -> it.event?.countMemory()?.toLong() ?: 0L })
qttNotes.toList().sortedByDescending { bytesNotes[it.first] }.forEach { (kind, qtt) ->
Log.d(STATE_DUMP_TAG, "Kind ${kind.toString().padStart(5,' ')}:\t${qtt.toString().padStart(6,' ')} elements\t${bytesNotes[kind]?.div((1024 * 1024))}MB ")
Log.d(STATE_DUMP_TAG) { "Kind ${kind.toString().padStart(5,' ')}:\t${qtt.toString().padStart(6,' ')} elements\t${bytesNotes[kind]?.div((1024 * 1024))}MB " }
}
qttAddressables.toList().sortedByDescending { bytesNotes[it.first] }.forEach { (kind, qtt) ->
Log.d(STATE_DUMP_TAG, "Kind ${kind.toString().padStart(5,' ')}:\t${qtt.toString().padStart(6,' ')} elements\t${bytesAddressables[kind]?.div((1024 * 1024))}MB ")
Log.d(STATE_DUMP_TAG) { "Kind ${kind.toString().padStart(5,' ')}:\t${qtt.toString().padStart(6,' ')} elements\t${bytesAddressables[kind]?.div((1024 * 1024))}MB " }
}
}
@@ -188,7 +181,7 @@ inline fun <T> logTime(
if (isDebug) {
val (result, elapsed) = measureTimedValue(block)
if (elapsed.inWholeMilliseconds > minToReportMs) {
Log.d("DEBUG-TIME", "${elapsed.toString(DurationUnit.MILLISECONDS, 3).padStart(12)}: $debugMessage")
Log.d("DEBUG-TIME") { "${elapsed.toString(DurationUnit.MILLISECONDS, 3).padStart(12)}: $debugMessage" }
}
result
} else {
@@ -203,7 +196,7 @@ inline fun <T> logTime(
if (isDebug) {
val (result, elapsed) = measureTimedValue(block)
if (elapsed.inWholeMilliseconds > minToReportMs) {
Log.d("DEBUG-TIME", "${elapsed.toString(DurationUnit.MILLISECONDS, 3).padStart(12)}: ${debugMessage(result)}")
Log.d("DEBUG-TIME") { "${elapsed.toString(DurationUnit.MILLISECONDS, 3).padStart(12)}: ${debugMessage(result)}" }
}
result
} else {
@@ -282,7 +282,7 @@ object LocalPreferences {
*/
@SuppressLint("ApplySharedPref")
suspend fun deleteAccount(accountInfo: AccountInfo) {
Log.d("LocalPreferences", "Saving to encrypted storage updatePrefsForLogout ${accountInfo.npub}")
Log.d("LocalPreferences") { "Saving to encrypted storage updatePrefsForLogout ${accountInfo.npub}" }
withContext(Dispatchers.IO) {
encryptedPreferences(accountInfo.npub).edit(commit = true) { clear() }
removeAccount(accountInfo)
@@ -446,18 +446,18 @@ object LocalPreferences {
}
private suspend fun innerLoadCurrentAccountFromEncryptedStorage(npub: String?): AccountSettings? {
Log.d("LocalPreferences", "Load account from file $npub")
Log.d("LocalPreferences") { "Load account from file $npub" }
val result =
withContext(Dispatchers.IO) {
return@withContext with(encryptedPreferences(npub)) {
Log.d("LocalPreferences", "Load account from file $npub - opened file")
Log.d("LocalPreferences") { "Load account from file $npub - opened file" }
val privKey = getString(PrefKeys.NOSTR_PRIVKEY, null)
val pubKey = getString(PrefKeys.NOSTR_PUBKEY, null) ?: return@with null
val externalSignerPackageName = getString(PrefKeys.SIGNER_PACKAGE_NAME, null) ?: if (getBoolean(PrefKeys.LOGIN_WITH_EXTERNAL_SIGNER, false)) "com.greenart7c3.nostrsigner" else null
val keyPair = KeyPair(privKey = privKey?.hexToByteArray(), pubKey = pubKey.hexToByteArray())
Log.d("LocalPreferences", "Load account from file $npub - keys ready")
Log.d("LocalPreferences") { "Load account from file $npub - keys ready" }
val stripLocationOnUpload = getBoolean(PrefKeys.STRIP_LOCATION_ON_UPLOAD, true)
val hideDeleteRequestDialog = getBoolean(PrefKeys.HIDE_DELETE_REQUEST_DIALOG, false)
@@ -495,7 +495,7 @@ object LocalPreferences {
val latestPaymentTargetsStr = getString(PrefKeys.LATEST_PAYMENT_TARGETS, null)
val lastReadPerRouteStr = getString(PrefKeys.LAST_READ_PER_ROUTE, null)
Log.d("LocalPreferences", "Load account from file $npub - before parsing events")
Log.d("LocalPreferences") { "Load account from file $npub - before parsing events" }
val defaultHomeFollowList = async { parseOrNull<TopFilter>(defaultHomeFollowListStr) ?: TopFilter.AllFollows }
val defaultStoriesFollowList = async { parseOrNull<TopFilter>(defaultStoriesFollowListStr) ?: TopFilter.Global }
@@ -532,7 +532,7 @@ object LocalPreferences {
} ?: mapOf()
}
Log.d("LocalPreferences", "Load account from file $npub - asyncs created")
Log.d("LocalPreferences") { "Load account from file $npub - asyncs created" }
return@with AccountSettings(
keyPair = keyPair,
@@ -574,7 +574,7 @@ object LocalPreferences {
)
}
}
Log.d("LocalPreferences", "Loaded account from file $npub")
Log.d("LocalPreferences") { "Loaded account from file $npub" }
return result
}
@@ -2582,17 +2582,17 @@ object LocalCache : ILocalCache, ICacheProvider {
}
fun cleanMemory() {
Log.d("LargeCache", "Notes cleanup started. Current size: ${notes.size()}")
Log.d("LargeCache") { "Notes cleanup started. Current size: ${notes.size()}" }
notes.cleanUp()
Log.d("LargeCache", "Notes cleanup completed. Remaining size: ${notes.size()}")
Log.d("LargeCache") { "Notes cleanup completed. Remaining size: ${notes.size()}" }
Log.d("LargeCache", "Addressables cleanup started. Current size: ${addressables.size()}")
Log.d("LargeCache") { "Addressables cleanup started. Current size: ${addressables.size()}" }
addressables.cleanUp()
Log.d("LargeCache", "Addressables cleanup completed. Remaining size: ${addressables.size()}")
Log.d("LargeCache") { "Addressables cleanup completed. Remaining size: ${addressables.size()}" }
Log.d("LargeCache", "Users cleanup started. Current size: ${users.size()}")
Log.d("LargeCache") { "Users cleanup started. Current size: ${users.size()}" }
users.cleanUp()
Log.d("LargeCache", "Users cleanup completed. Remaining size: ${users.size()}")
Log.d("LargeCache") { "Users cleanup completed. Remaining size: ${users.size()}" }
}
fun cleanObservers() {
@@ -2998,7 +2998,7 @@ object LocalCache : ILocalCache, ICacheProvider {
getNoteIfExists(deletionEvent.id)?.let { note ->
if (!note.hasRelay(relay.url)) {
if (isDebug) {
Log.d("LocalCache", "Updating ${relay.url.url} with a Deletion Event ${event.id} ${deletionEvent.id} because of ${event.toJson()} with ${deletionEvent.toJson()}")
Log.d("LocalCache") { "Updating ${relay.url.url} with a Deletion Event ${event.id} ${deletionEvent.id} because of ${event.toJson()} with ${deletionEvent.toJson()}" }
}
relay.sendIfConnected(EventCmd(deletionEvent))
note.addRelay(relay.url)
@@ -3015,7 +3015,7 @@ object LocalCache : ILocalCache, ICacheProvider {
note.event?.let { existingEvent ->
if (existingEvent.createdAt > event.createdAt && !note.hasRelay(relay.url) && !deletionIndex.hasBeenDeleted(event) && !event.isExpired()) {
if (isDebug) {
Log.d("LocalCache", "Updating ${relay.url.url} with a new version of ${event.kind} ${event.id} to ${existingEvent.id}")
Log.d("LocalCache") { "Updating ${relay.url.url} with a new version of ${event.kind} ${event.id} to ${existingEvent.id}" }
}
relay.sendIfConnected(EventCmd(existingEvent))
@@ -91,7 +91,7 @@ class PrivateStorageRelayListState(
init {
settings.backupPrivateHomeRelayList?.let { event ->
Log.d("AccountRegisterObservers", "Loading saved private home relay list ${event.toJson()}")
Log.d("AccountRegisterObservers") { "Loading saved private home relay list ${event.toJson()}" }
@OptIn(DelicateCoroutinesApi::class)
scope.launch(Dispatchers.IO) {
LocalCache.justConsumeMyOwnEvent(event)
@@ -101,7 +101,7 @@ class PrivateStorageRelayListState(
scope.launch(Dispatchers.IO) {
Log.d("AccountRegisterObservers", "Private Home Relay List Collector Start")
getPrivateOutboxRelayListFlow().collect { noteState ->
Log.d("AccountRegisterObservers", "Updating Private Home Relay List for ${signer.pubKey}")
Log.d("AccountRegisterObservers") { "Updating Private Home Relay List for ${signer.pubKey}" }
(noteState.note.event as? PrivateOutboxRelayListEvent)?.let {
settings.updatePrivateHomeRelayList(it)
}
@@ -132,7 +132,7 @@ class UserMetadataState(
init {
settings.backupUserMetadata?.let {
Log.d("AccountRegisterObservers", "Loading saved user metadata ${it.toJson()}")
Log.d("AccountRegisterObservers") { "Loading saved user metadata ${it.toJson()}" }
@OptIn(DelicateCoroutinesApi::class)
scope.launch(Dispatchers.IO) { LocalCache.justConsumeMyOwnEvent(it) }
@@ -142,7 +142,7 @@ class UserMetadataState(
scope.launch(Dispatchers.IO) {
Log.d("AccountRegisterObservers", "Kind 0 Collector Start")
getUserMetadataFlow().collect {
Log.d("AccountRegisterObservers", "Updating Kind 0 ${user.toBestDisplayName()}")
Log.d("AccountRegisterObservers") { "Updating Kind 0 ${user.toBestDisplayName()}" }
(it.note.event as? MetadataEvent)?.let {
settings.updateUserMetadata(it)
}
@@ -162,7 +162,7 @@ class Kind3FollowListState(
init {
settings.backupContactList?.let {
Log.d("AccountRegisterObservers", "Loading saved ${it.tags.size} contacts")
Log.d("AccountRegisterObservers") { "Loading saved ${it.tags.size} contacts" }
@OptIn(DelicateCoroutinesApi::class)
scope.launch(Dispatchers.IO) { LocalCache.justConsumeMyOwnEvent(it) }
@@ -172,7 +172,7 @@ class Kind3FollowListState(
scope.launch(Dispatchers.IO) {
Log.d("AccountRegisterObservers", "Kind 3 Collector Start")
getFollowListFlow().collect {
Log.d("AccountRegisterObservers", "Updating Kind 3 ${signer.pubKey}")
Log.d("AccountRegisterObservers") { "Updating Kind 3 ${signer.pubKey}" }
(it.note.event as? ContactListEvent)?.let {
settings.updateContactListTo(it)
}
@@ -55,7 +55,7 @@ class OtsState(
}
suspend fun updateAttestations(): List<OtsEvent> {
Log.d("Pending Attestations", "Updating ${settings.pendingAttestations.value.size} pending attestations")
Log.d("Pending Attestations") { "Updating ${settings.pendingAttestations.value.size} pending attestations" }
return settings.pendingAttestations.value.toList().mapNotNull { (key, value) ->
val otsState = OtsEvent.upgrade(Base64.getDecoder().decode(value), key, otsResolver())
@@ -88,7 +88,7 @@ class DmRelayListState(
init {
settings.backupDMRelayList?.let {
Log.d("AccountRegisterObservers", "Loading saved DM Relay List ${it.toJson()}")
Log.d("AccountRegisterObservers") { "Loading saved DM Relay List ${it.toJson()}" }
@OptIn(DelicateCoroutinesApi::class)
scope.launch(Dispatchers.IO) {
LocalCache.justConsumeMyOwnEvent(it)
@@ -98,7 +98,7 @@ class DmRelayListState(
scope.launch(Dispatchers.IO) {
Log.d("AccountRegisterObservers", "NIP-17 Relay List Collector Start")
getDMRelayListFlow().collect {
Log.d("AccountRegisterObservers", "Updating DM Relay List for ${signer.pubKey}")
Log.d("AccountRegisterObservers") { "Updating DM Relay List for ${signer.pubKey}" }
(it.note.event as? ChatMessageRelayListEvent)?.let {
settings.updateDMRelayList(it)
}
@@ -93,7 +93,7 @@ class BlockedRelayListState(
init {
settings.backupBlockedRelayList?.let {
Log.d("AccountRegisterObservers", "Loading saved Blocked relay list ${it.toJson()}")
Log.d("AccountRegisterObservers") { "Loading saved Blocked relay list ${it.toJson()}" }
@OptIn(DelicateCoroutinesApi::class)
scope.launch(Dispatchers.IO) { LocalCache.justConsumeMyOwnEvent(it) }
}
@@ -101,7 +101,7 @@ class BlockedRelayListState(
scope.launch(Dispatchers.IO) {
Log.d("AccountRegisterObservers", "Blocked Relay List Collector Start")
getBlockedRelayListFlow().collect {
Log.d("AccountRegisterObservers", "Updating Blocked Relay List for ${signer.pubKey}")
Log.d("AccountRegisterObservers") { "Updating Blocked Relay List for ${signer.pubKey}" }
(it.note.event as? BlockedRelayListEvent)?.let {
settings.updateBlockedRelayList(it)
}
@@ -106,7 +106,7 @@ class GeohashListState(
init {
settings.backupGeohashList?.let { event ->
Log.d("AccountRegisterObservers", "Loading saved Geohash list ${event.toJson()}")
Log.d("AccountRegisterObservers") { "Loading saved Geohash list ${event.toJson()}" }
@OptIn(DelicateCoroutinesApi::class)
scope.launch(Dispatchers.IO) {
LocalCache.justConsumeMyOwnEvent(event)
@@ -116,7 +116,7 @@ class GeohashListState(
scope.launch(Dispatchers.IO) {
Log.d("AccountRegisterObservers", "Geohash List Collector Start")
getGeohashListFlow().collect { noteState ->
Log.d("AccountRegisterObservers", "Geohash List for ${signer.pubKey}")
Log.d("AccountRegisterObservers") { "Geohash List for ${signer.pubKey}" }
(noteState.note.event as? GeohashListEvent)?.let {
settings.updateGeohashListTo(it)
}
@@ -106,7 +106,7 @@ class HashtagListState(
init {
settings.backupHashtagList?.let { event ->
Log.d("AccountRegisterObservers", "Loading saved Hashtag list ${event.toJson()}")
Log.d("AccountRegisterObservers") { "Loading saved Hashtag list ${event.toJson()}" }
@OptIn(DelicateCoroutinesApi::class)
scope.launch(Dispatchers.IO) {
LocalCache.justConsumeMyOwnEvent(event)
@@ -116,7 +116,7 @@ class HashtagListState(
scope.launch(Dispatchers.IO) {
Log.d("AccountRegisterObservers", "Hashtag List Collector Start")
getHashtagListFlow().collect {
Log.d("AccountRegisterObservers", "Hashtag List for ${signer.pubKey}")
Log.d("AccountRegisterObservers") { "Hashtag List for ${signer.pubKey}" }
(it.note.event as? HashtagListEvent)?.let {
settings.updateHashtagListTo(it)
}
@@ -103,7 +103,7 @@ class IndexerRelayListState(
init {
settings.backupIndexRelayList?.let {
Log.d("AccountRegisterObservers", "Loading saved index relay list ${it.toJson()}")
Log.d("AccountRegisterObservers") { "Loading saved index relay list ${it.toJson()}" }
@OptIn(DelicateCoroutinesApi::class)
scope.launch(Dispatchers.IO) { LocalCache.justConsumeMyOwnEvent(it) }
}
@@ -111,7 +111,7 @@ class IndexerRelayListState(
scope.launch(Dispatchers.IO) {
Log.d("AccountRegisterObservers", "Index Relay List Collector Start")
getIndexerRelayListFlow().collect {
Log.d("AccountRegisterObservers", "Updating Index Relay List for ${signer.pubKey}")
Log.d("AccountRegisterObservers") { "Updating Index Relay List for ${signer.pubKey}" }
(it.note.event as? IndexerRelayListEvent)?.let {
settings.updateIndexRelayList(it)
}
@@ -141,7 +141,7 @@ class MuteListState(
init {
settings.backupMuteList?.let { event ->
Log.d("AccountRegisterObservers", "Loading saved mute list ${event.toJson()}")
Log.d("AccountRegisterObservers") { "Loading saved mute list ${event.toJson()}" }
@OptIn(DelicateCoroutinesApi::class)
scope.launch(Dispatchers.IO) {
LocalCache.justConsumeMyOwnEvent(event)
@@ -151,7 +151,7 @@ class MuteListState(
scope.launch(Dispatchers.IO) {
Log.d("AccountRegisterObservers", "Mute List Collector Start")
getMuteListFlow().collect {
Log.d("AccountRegisterObservers", "Updating Mute List for ${signer.pubKey}")
Log.d("AccountRegisterObservers") { "Updating Mute List for ${signer.pubKey}" }
(it.note.event as? MuteListEvent)?.let {
settings.updateMuteList(it)
}
@@ -115,7 +115,7 @@ class RelayFeedListState(
init {
settings.backupRelayFeedsList?.let {
Log.d("AccountRegisterObservers", "Loading saved relay feeds list ${it.toJson()}")
Log.d("AccountRegisterObservers") { "Loading saved relay feeds list ${it.toJson()}" }
@OptIn(DelicateCoroutinesApi::class)
scope.launch(Dispatchers.IO) { LocalCache.justConsumeMyOwnEvent(it) }
}
@@ -123,7 +123,7 @@ class RelayFeedListState(
scope.launch(Dispatchers.IO) {
Log.d("AccountRegisterObservers", "Relay feeds list Collector Start")
getRelayFeedsListFlow().collect {
Log.d("AccountRegisterObservers", "Updating Relay feeds list for ${signer.pubKey}")
Log.d("AccountRegisterObservers") { "Updating Relay feeds list for ${signer.pubKey}" }
(it.note.event as? RelayFeedsListEvent)?.let {
settings.updateRelayFeedList(it)
}
@@ -103,7 +103,7 @@ class SearchRelayListState(
init {
settings.backupSearchRelayList?.let {
Log.d("AccountRegisterObservers", "Loading saved search relay list ${it.toJson()}")
Log.d("AccountRegisterObservers") { "Loading saved search relay list ${it.toJson()}" }
@OptIn(DelicateCoroutinesApi::class)
scope.launch(Dispatchers.IO) { LocalCache.justConsumeMyOwnEvent(it) }
}
@@ -111,7 +111,7 @@ class SearchRelayListState(
scope.launch(Dispatchers.IO) {
Log.d("AccountRegisterObservers", "Search Relay List Collector Start")
getSearchRelayListFlow().collect {
Log.d("AccountRegisterObservers", "Updating Search Relay List for ${signer.pubKey}")
Log.d("AccountRegisterObservers") { "Updating Search Relay List for ${signer.pubKey}" }
(it.note.event as? SearchRelayListEvent)?.let {
settings.updateSearchRelayList(it)
}
@@ -90,7 +90,7 @@ class TrustedRelayListState(
init {
settings.backupTrustedRelayList?.let {
Log.d("AccountRegisterObservers", "Loading saved Trusted relay list ${it.toJson()}")
Log.d("AccountRegisterObservers") { "Loading saved Trusted relay list ${it.toJson()}" }
@OptIn(DelicateCoroutinesApi::class)
scope.launch(Dispatchers.IO) { cache.justConsumeMyOwnEvent(it) }
}
@@ -98,7 +98,7 @@ class TrustedRelayListState(
scope.launch(Dispatchers.IO) {
Log.d("AccountRegisterObservers", "Trusted Relay List Collector Start")
getTrustedRelayListFlow().collect {
Log.d("AccountRegisterObservers", "Updating Trusted Relay List for ${signer.pubKey}")
Log.d("AccountRegisterObservers") { "Updating Trusted Relay List for ${signer.pubKey}" }
(it.note.event as? TrustedRelayListEvent)?.let {
settings.updateTrustedRelayList(it)
}
@@ -144,7 +144,7 @@ class Nip65RelayListState(
init {
settings.backupNIP65RelayList?.let {
Log.d("AccountRegisterObservers", "Loading saved nip65 relay list ${it.toJson()}")
Log.d("AccountRegisterObservers") { "Loading saved nip65 relay list ${it.toJson()}" }
@OptIn(DelicateCoroutinesApi::class)
scope.launch(Dispatchers.IO) { cache.justConsumeMyOwnEvent(it) }
}
@@ -152,7 +152,7 @@ class Nip65RelayListState(
scope.launch(Dispatchers.IO) {
Log.d("AccountRegisterObservers", "NIP-65 Relay List Collector Start")
getNIP65RelayListFlow().collect {
Log.d("AccountRegisterObservers", "Updating NIP-65 List for ${signer.pubKey}")
Log.d("AccountRegisterObservers") { "Updating NIP-65 List for ${signer.pubKey}" }
(it.note.event as? AdvertisedRelayListEvent)?.let {
settings.updateNIP65RelayList(it)
}
@@ -155,7 +155,7 @@ class CommunityListState(
init {
settings.backupCommunityList?.let { event ->
Log.d("AccountRegisterObservers", "Loading saved Community list ${event.toJson()}")
Log.d("AccountRegisterObservers") { "Loading saved Community list ${event.toJson()}" }
@OptIn(DelicateCoroutinesApi::class)
scope.launch(Dispatchers.IO) {
LocalCache.justConsumeMyOwnEvent(event)
@@ -165,7 +165,7 @@ class CommunityListState(
scope.launch(Dispatchers.IO) {
Log.d("AccountRegisterObservers", "Community List Collector Start")
getCommunityListFlow().collect {
Log.d("AccountRegisterObservers", "Community List for ${signer.pubKey}")
Log.d("AccountRegisterObservers") { "Community List for ${signer.pubKey}" }
(it.note.event as? CommunityListEvent)?.let {
settings.updateCommunityListTo(it)
}
@@ -65,7 +65,7 @@ class AppSpecificState(
init {
if (settings.isWriteable()) {
settings.backupAppSpecificData?.let { event ->
Log.d("AccountRegisterObservers", "Loading saved app specific data ${event.toJson()}")
Log.d("AccountRegisterObservers") { "Loading saved app specific data ${event.toJson()}" }
@OptIn(DelicateCoroutinesApi::class)
scope.launch(Dispatchers.IO) {
LocalCache.justConsumeMyOwnEvent(event)
@@ -84,7 +84,7 @@ class AppSpecificState(
Log.d("AccountRegisterObservers", "AppSpecificData Collector Start")
getAppSpecificDataFlow().collect {
try {
Log.d("AccountRegisterObservers", "Updating AppSpecificData for ${signer.pubKey}")
Log.d("AccountRegisterObservers") { "Updating AppSpecificData for ${signer.pubKey}" }
(it.note.event as? AppSpecificDataEvent)?.let {
val decrypted = signer.decrypt(it.content, it.pubKey)
try {
@@ -46,7 +46,7 @@ class NipA3PaymentTargetsState(
init {
settings.backupNipA3PaymentTargets?.let {
Log.d("AccountRegisterObservers", "Loading saved nipA3 Payment targets ${it.toJson()}")
Log.d("AccountRegisterObservers") { "Loading saved nipA3 Payment targets ${it.toJson()}" }
@OptIn(DelicateCoroutinesApi::class)
scope.launch(Dispatchers.IO) { cache.justConsumeMyOwnEvent(it) }
}
@@ -54,7 +54,7 @@ class NipA3PaymentTargetsState(
scope.launch(Dispatchers.IO) {
Log.d("AccountRegisterObservers", "nipA3 Payment targets Collector Start")
getNipA3PaymentTargetsFlow().collect {
Log.d("AccountRegisterObservers", "Updating nipA3 Payment targets for ${signer.pubKey}")
Log.d("AccountRegisterObservers") { "Updating nipA3 Payment targets for ${signer.pubKey}" }
(it.note.event as? PaymentTargetsEvent)?.let { paymentTargetsEvent ->
settings.updateNIPA3PaymentTargets(paymentTargetsEvent)
}
@@ -124,7 +124,7 @@ class TrustProviderListState(
scope.launch(Dispatchers.IO) {
Log.d("AccountRegisterObservers", "TrustProviderList Collector Start")
getTrustProviderListFlow().collect { noteState ->
Log.d("AccountRegisterObservers", "TrustProviderList List for ${signer.pubKey}")
Log.d("AccountRegisterObservers") { "TrustProviderList List for ${signer.pubKey}" }
(noteState.note.event as? TrustProviderListEvent)?.let {
settings.updateTrustProviderListTo(it)
}
@@ -85,7 +85,7 @@ class BroadcastTracker {
// Add to active broadcasts and cache event for retries
_activeBroadcasts.update { (it + broadcast).toImmutableList() }
Log.d(TAG, "Starting broadcast $trackingId (kind ${event.kind}) to ${relays.size} relays")
Log.d(TAG) { "Starting broadcast $trackingId (kind ${event.kind}) to ${relays.size} relays" }
val resultChannel = Channel<RelayResponse>(UNLIMITED)
@@ -102,7 +102,7 @@ class BroadcastTracker {
result = RelayResult.Error(errorMessage),
),
)
Log.d(TAG, "[$trackingId] Cannot connect to ${relay.url}: $errorMessage")
Log.d(TAG) { "[$trackingId] Cannot connect to ${relay.url}: $errorMessage" }
}
}
@@ -114,7 +114,7 @@ class BroadcastTracker {
result = RelayResult.Error("Relay disconnected before completion"),
),
)
Log.d(TAG, "[$trackingId] Disconnected from ${relay.url}")
Log.d(TAG) { "[$trackingId] Disconnected from ${relay.url}" }
}
}
@@ -135,7 +135,7 @@ class BroadcastTracker {
RelayResult.Error(msg.message)
}
resultChannel.trySend(RelayResponse(relay.url, result))
Log.d(TAG, "[$trackingId] Response from ${relay.url}: success=${msg.success} message=${msg.message}")
Log.d(TAG) { "[$trackingId] Response from ${relay.url}: success=${msg.success} message=${msg.message}" }
}
}
}
@@ -190,7 +190,7 @@ class BroadcastTracker {
list.map { if (it.id == trackingId) finalBroadcast else it }.toImmutableList()
}
Log.d(TAG, "Broadcast $trackingId complete: ${finalBroadcast.successCount}/${finalBroadcast.totalRelays} success")
Log.d(TAG) { "Broadcast $trackingId complete: ${finalBroadcast.successCount}/${finalBroadcast.totalRelays} success" }
} finally {
client.removeConnectionListener(subscription)
}
@@ -278,7 +278,7 @@ class BroadcastTracker {
result = RelayResult.Error(errorMessage),
),
)
Log.d(TAG, "[${broadcast.id}] Retry cannot connect to ${relay.url}: $errorMessage")
Log.d(TAG) { "[${broadcast.id}] Retry cannot connect to ${relay.url}: $errorMessage" }
}
}
@@ -290,7 +290,7 @@ class BroadcastTracker {
result = RelayResult.Error("Relay disconnected before completion"),
),
)
Log.d(TAG, "[${broadcast.id}] Retry disconnected from ${relay.url}")
Log.d(TAG) { "[${broadcast.id}] Retry disconnected from ${relay.url}" }
}
}
@@ -311,7 +311,7 @@ class BroadcastTracker {
RelayResult.Error(msg.message)
}
resultChannel.trySend(RelayResponse(relay.url, result))
Log.d(TAG, "[${broadcast.id}] Retry response from ${relay.url}: success=${msg.success}")
Log.d(TAG) { "[${broadcast.id}] Retry response from ${relay.url}: success=${msg.success}" }
}
}
}
@@ -383,7 +383,7 @@ class BroadcastTracker {
list.map { if (it.id == broadcast.id) finalBroadcast else it }.toImmutableList()
}
Log.d(TAG, "Retry complete for ${broadcast.id}: ${finalBroadcast.successCount}/${finalBroadcast.totalRelays} success")
Log.d(TAG) { "Retry complete for ${broadcast.id}: ${finalBroadcast.successCount}/${finalBroadcast.totalRelays} success" }
return finalBroadcast
}
@@ -48,7 +48,7 @@ class ConnectivityFlow(
object : ConnectivityManager.NetworkCallback() {
override fun onAvailable(network: Network) {
super.onAvailable(network)
Log.d("ConnectivityFlow", "onAvailable ${network.networkHandle}")
Log.d("ConnectivityFlow") { "onAvailable ${network.networkHandle}" }
connectivityManager.getNetworkCapabilities(network)?.let {
trySend(ConnectivityStatus.Active(network.networkHandle, it.isMeteredOrMobileData()))
}
@@ -60,13 +60,13 @@ class ConnectivityFlow(
) {
super.onCapabilitiesChanged(network, networkCapabilities)
val isMobile = networkCapabilities.isMeteredOrMobileData()
Log.d("ConnectivityFlow", "onCapabilitiesChanged ${network.networkHandle} $isMobile")
Log.d("ConnectivityFlow") { "onCapabilitiesChanged ${network.networkHandle} $isMobile" }
trySend(ConnectivityStatus.Active(network.networkHandle, isMobile))
}
override fun onLost(network: Network) {
super.onLost(network)
Log.d("ConnectivityFlow", "onLost ${network.networkHandle} ")
Log.d("ConnectivityFlow") { "onLost ${network.networkHandle} " }
trySend(ConnectivityStatus.Off)
}
}
@@ -188,7 +188,7 @@ class LightningAddressResolver {
}
if (errorMessage == null) {
Log.d("LightningAddressResolver", "Error parsing LNResponse: $body")
Log.d("LightningAddressResolver") { "Error parsing LNResponse: $body" }
}
return errorMessage
@@ -48,13 +48,13 @@ class LocationFlow(
val locationCallback =
LocationListener { location ->
Log.d("LocationFlow", "onLocationChanged $location")
Log.d("LocationFlow") { "onLocationChanged $location" }
launch { send(location) }
}
locationManager.allProviders.forEach {
val location = locationManager.getLastKnownLocation(it)
Log.d("LocationFlow", "Last Known location is $location")
Log.d("LocationFlow") { "Last Known location is $location" }
if (location != null) {
send(location)
}
@@ -53,7 +53,7 @@ class ReverseGeolocation {
val locationCallback =
object : Geocoder.GeocodeListener {
override fun onGeocode(addresses: List<Address>) {
Log.d("ReverseGeoLocation", "Found ${addresses.size} new addresses")
Log.d("ReverseGeoLocation") { "Found ${addresses.size} new addresses" }
onReady(addresses)
}
@@ -64,7 +64,7 @@ class ReverseGeolocation {
}
}
Log.d("ReverseGeoLocation", "Execute Async $location")
Log.d("ReverseGeoLocation") { "Execute Async $location" }
Geocoder(context).getFromLocation(
location.latitude,
location.longitude,
@@ -77,7 +77,7 @@ class ReverseGeolocation {
location: Location,
context: Context,
): List<Address>? {
Log.d("ReverseGeoLocation", "Execute Sync $location")
Log.d("ReverseGeoLocation") { "Execute Sync $location" }
return try {
Geocoder(context).getFromLocation(
location.latitude,
@@ -60,7 +60,7 @@ class LogMonitor : Printer {
val endTime = System.currentTimeMillis()
if (x.indexOf("com.vitorpamplona.amethyst") > 0) {
Log.d("block-canary", "Looper ${endTime - mStartTimestamp}ms for $x")
Log.d("block-canary") { "Looper ${endTime - mStartTimestamp}ms for $x" }
}
mPrintingStarted = false
@@ -67,14 +67,14 @@ class EventNotificationConsumer(
LocalPreferences.allSavedAccounts().forEach {
if (!matchAccount && (it.hasPrivKey || it.loggedInWithExternalSigner)) {
LocalPreferences.loadAccountConfigFromEncryptedStorage(it.npub)?.let { acc ->
Log.d(TAG, "New Notification Testing if for ${it.npub}")
Log.d(TAG) { "New Notification Testing if for ${it.npub}" }
try {
val account = Amethyst.instance.accountsCache.loadAccount(acc)
consumeIfMatchesAccount(event, account)
matchAccount = true
} catch (e: Exception) {
if (e is CancellationException) throw e
Log.d(TAG, "Message was not for user ${it.npub}: ${e.message}")
Log.d(TAG) { "Message was not for user ${it.npub}: ${e.message}" }
}
}
}
@@ -94,14 +94,14 @@ class EventNotificationConsumer(
account: Account,
) {
val consumed = LocalCache.hasConsumed(notificationEvent)
Log.d(TAG, "New Notification ${notificationEvent.kind} ${notificationEvent.id} Arrived for ${account.signer.pubKey} consumed= $consumed")
Log.d(TAG) { "New Notification ${notificationEvent.kind} ${notificationEvent.id} Arrived for ${account.signer.pubKey} consumed= $consumed" }
if (!consumed) {
Log.d(TAG, "New Notification was verified")
if (!notificationManager().areNotificationsEnabled()) return
Log.d(TAG, "Notifications are enabled")
unwrapAndConsume(notificationEvent, account.signer)?.let { innerEvent ->
Log.d(TAG, "Unwrapped consume ${innerEvent.javaClass.simpleName}")
Log.d(TAG) { "Unwrapped consume ${innerEvent.javaClass.simpleName}" }
when (innerEvent) {
is PrivateDmEvent -> notify(innerEvent, account)
@@ -124,14 +124,14 @@ class EventNotificationConsumer(
LocalPreferences.allSavedAccounts().forEach {
if (!matchAccount && (it.hasPrivKey || it.loggedInWithExternalSigner) && it.npub in npubs) {
LocalPreferences.loadAccountConfigFromEncryptedStorage(it.npub)?.let { accountSettings ->
Log.d(TAG, "New Notification Testing if for ${it.npub}")
Log.d(TAG) { "New Notification Testing if for ${it.npub}" }
try {
val account = Amethyst.instance.accountsCache.loadAccount(accountSettings)
consumeNotificationEvent(event, account)
matchAccount = true
} catch (e: Exception) {
if (e is CancellationException) throw e
Log.d(TAG, "Message was not for user ${it.npub}: ${e.message}")
Log.d(TAG) { "Message was not for user ${it.npub}: ${e.message}" }
}
}
}
@@ -365,7 +365,7 @@ class EventNotificationConsumer(
account: Account,
) {
Log.d(TAG, "New Zap to Notify")
Log.d(TAG, "Notify Start ${event.toNostrUri()}")
Log.d(TAG) { "Notify Start ${event.toNostrUri()}" }
LocalCache.getNoteIfExists(event.id) ?: return
Log.d(TAG, "Notify Not Notified Yet")
@@ -378,7 +378,7 @@ class EventNotificationConsumer(
val noteZapRequest = event.zapRequest?.id?.let { LocalCache.checkGetOrCreateNote(it) } ?: return
val noteZapped = event.zappedPost().firstOrNull()?.let { LocalCache.checkGetOrCreateNote(it) } ?: return
Log.d(TAG, "Notify ZapRequest $noteZapRequest zapped $noteZapped")
Log.d(TAG) { "Notify ZapRequest $noteZapRequest zapped $noteZapped" }
if ((event.amount ?: BigDecimal.ZERO) < BigDecimal.TEN) return
@@ -387,11 +387,11 @@ class EventNotificationConsumer(
if (event.isTaggedUser(account.signer.pubKey)) {
val amount = showAmount(event.amount)
Log.d(TAG, "Notify Amount $amount")
Log.d(TAG) { "Notify Amount $amount" }
(noteZapRequest.event as? LnZapRequestEvent)?.let { event ->
decryptZapContentAuthor(event, account.signer)?.let { decryptedEvent ->
Log.d(TAG, "Notify Decrypted if Private Zap ${event.id}")
Log.d(TAG) { "Notify Decrypted if Private Zap ${event.id}" }
val author = LocalCache.getOrCreateUser(decryptedEvent.pubKey)
val senderInfo = Pair(author, decryptedEvent.content.ifBlank { null })
@@ -428,7 +428,7 @@ class EventNotificationConsumer(
.hexToByteArray()
.toNpub()
Log.d(TAG, "Notify ${event.id} $content $title $noteUri")
Log.d(TAG) { "Notify ${event.id} $content $title $noteUri" }
notificationManager()
.sendZapNotification(
@@ -463,7 +463,7 @@ class EventNotificationConsumer(
.hexToByteArray()
.toNpub()
Log.d(TAG, "Notify ${event.id} $title $noteUri")
Log.d(TAG) { "Notify ${event.id} $title $noteUri" }
notificationManager()
.sendZapNotification(
@@ -69,7 +69,7 @@ class PokeyReceiver : BroadcastReceiver() {
) {
if (intent.action == POKEY_ACTION) { // it's best practice to verify intent action before performing any operation
val eventStr = intent.getStringExtra("EVENT")
Log.d(TAG, "New Pokey Notification Arrived $eventStr")
Log.d(TAG) { "New Pokey Notification Arrived $eventStr" }
if (eventStr == null) return
@@ -78,7 +78,7 @@ class RegisterAccounts(
accounts
.mapNotNull { account ->
if (account.hasPrivKey || account.loggedInWithExternalSigner) {
Log.d(tag, "Register Account ${account.npub}")
Log.d(tag) { "Register Account ${account.npub}" }
val acc = LocalPreferences.loadAccountConfigFromEncryptedStorage(account.npub)
if (acc != null && acc.isWriteable()) {
@@ -87,10 +87,10 @@ class RegisterAccounts(
if (isDebug) {
val readRelays = nip65Read.joinToString(", ") { it.url }
Log.d(tag, "Register Account ${account.npub} NIP65 Reads $readRelays")
Log.d(tag) { "Register Account ${account.npub} NIP65 Reads $readRelays" }
val dmRelays = nip17Read.joinToString(", ") { it.url }
Log.d(tag, "Register Account ${account.npub} NIP17 Reads $dmRelays")
Log.d(tag) { "Register Account ${account.npub} NIP17 Reads $dmRelays" }
}
val relays = (nip65Read + nip17Read)
@@ -41,7 +41,7 @@ class LoggingInterceptor : Interceptor {
val response: Response = chain.proceed(request)
val t2 = System.nanoTime()
Log.d("OkHttpLog", "Req $port ${request.url} in ${(t2 - t1) / 1e6}ms")
Log.d("OkHttpLog") { "Req $port ${request.url} in ${(t2 - t1) / 1e6}ms" }
return response
}
@@ -47,7 +47,7 @@ fun GetVideoController(
keepPlaying = mediaItem.src.keepPlaying,
context = context,
).onEach { state ->
Log.d("PlaybackService", "Controller instance: ${state.controller}")
Log.d("PlaybackService") { "Controller instance: ${state.controller}" }
if (BackgroundMedia.isPlaying()) {
// There is a video playing, start this one on mute.
@@ -57,7 +57,7 @@ fun GetVideoController(
// There is no other video playing. Use the default mute state to
// decide if sound is on or not.
state.controller.volume = if (muted) 0f else 1f
Log.d("PlaybackService", "OnEach $muted")
Log.d("PlaybackService") { "OnEach $muted" }
}
if (play) {
@@ -67,14 +67,14 @@ object PlaybackServiceClient {
.setConnectionHints(bundle)
.buildAsync()
Log.d("PlaybackService", "Preparing Controller $id $videoUri")
Log.d("PlaybackService") { "Preparing Controller $id $videoUri" }
controllerFuture.addListener(
{
try {
val controller = controllerFuture.get(5, TimeUnit.SECONDS)
Log.d("PlaybackService", "Controller Ready $id $videoUri")
Log.d("PlaybackService") { "Controller Ready $id $videoUri" }
// checks if the player is still active before engaging further
trySend(
@@ -92,7 +92,7 @@ object PlaybackServiceClient {
)
awaitClose {
Log.d("PlaybackService", "Releasing Controller $id $videoUri")
Log.d("PlaybackService") { "Releasing Controller $id $videoUri" }
try {
MediaController.releaseFuture(controllerFuture)
} catch (e: Exception) {
@@ -74,7 +74,7 @@ class RelayProxyClientConnector(
if (it.connectivity is ConnectivityStatus.StartingService) {
// ignore
} else if (it.connectivity is ConnectivityStatus.Off) {
Log.d("ManageRelayServices", "Connectivity Off: Pausing Relay Services ${it.connectivity}")
Log.d("ManageRelayServices") { "Connectivity Off: Pausing Relay Services ${it.connectivity}" }
if (client.isActive()) {
client.disconnect()
}
@@ -80,7 +80,7 @@ class AuthCoordinator(
if (account == null) return
if (isDebug) {
Log.d("AuthCoordinator", "Watch $account")
Log.d("AuthCoordinator") { "Watch $account" }
}
authWithAccounts.add(account)
@@ -91,7 +91,7 @@ class AuthCoordinator(
if (account == null) return
if (isDebug) {
Log.d("AuthCoordinator", "Unwatch $account")
Log.d("AuthCoordinator") { "Unwatch $account" }
}
authWithAccounts.remove(account)
@@ -57,10 +57,10 @@ class FrameStat {
}
fun log() {
Log.d(TAG, "Events Per Second: ${eventCount.get()}")
Log.d(TAG) { "Events Per Second: ${eventCount.get()}" }
kinds.forEach { key, value ->
if (value.count.get() > 0) {
Log.d(TAG, "-- Kind $key $value")
Log.d(TAG) { "-- Kind $key $value" }
}
}
}
@@ -92,7 +92,7 @@ class MediaCompressor {
var tempFile: File? = null
return try {
Log.d("MediaCompressor", "Using image compression $mediaQuality")
Log.d("MediaCompressor") { "Using image compression $mediaQuality" }
tempFile = MediaCompressorFileUtils.from(uri, context)
val compressedImageFile =
Compressor.compress(context, tempFile) {
@@ -101,11 +101,11 @@ class MediaCompressor {
if (tempFile != compressedImageFile && !tempFile.delete()) {
Log.w("MediaCompressor", "Failed to delete temp file: ${tempFile.absolutePath}")
}
Log.d("MediaCompressor", "Image compression success. New size [${compressedImageFile.length()}]")
Log.d("MediaCompressor") { "Image compression success. New size [${compressedImageFile.length()}]" }
MediaCompressorResult(compressedImageFile.toUri(), MimeTypes.IMAGE_JPEG, compressedImageFile.length())
} catch (e: Exception) {
if (e is CancellationException) throw e
Log.d("MediaCompressor", "Image compression failed: ${e.message}")
Log.d("MediaCompressor") { "Image compression failed: ${e.message}" }
if (tempFile?.delete() == false) {
Log.w("MediaCompressor", "Failed to delete temp file: ${tempFile.absolutePath}")
}
@@ -225,7 +225,7 @@ object MetadataStripper {
if (tempFile?.delete() == false) {
Log.w("MetadataStripper", "Failed to delete temp file: ${tempFile.absolutePath}")
}
Log.d("MetadataStripper", "Failed to strip image metadata: ${e.message}")
Log.d("MetadataStripper") { "Failed to strip image metadata: ${e.message}" }
StrippingResult(uri, false)
}
}
@@ -260,7 +260,7 @@ object MetadataStripper {
StrippingResult(tempOutputFile.toUri(), true)
} catch (e: Exception) {
if (e is CancellationException) throw e
Log.d("MetadataStripper", "Failed to strip video metadata: ${e.message}")
Log.d("MetadataStripper") { "Failed to strip video metadata: ${e.message}" }
StrippingResult(uri, false)
}
}
@@ -293,7 +293,7 @@ object MetadataStripper {
StrippingResult(tempOutputFile.toUri(), true)
} catch (e: Exception) {
if (e is CancellationException) throw e
Log.d("MetadataStripper", "Failed to strip audio metadata: ${e.message}")
Log.d("MetadataStripper") { "Failed to strip audio metadata: ${e.message}" }
StrippingResult(uri, false)
}
}
@@ -387,7 +387,7 @@ object MetadataStripper {
if (tempInputFile?.delete() == false) {
Log.w("MetadataStripper", "Failed to delete temp file: ${tempInputFile.absolutePath}")
}
Log.d("MetadataStripper", "Failed to strip MP3 metadata: ${e.message}")
Log.d("MetadataStripper") { "Failed to strip MP3 metadata: ${e.message}" }
StrippingResult(uri, false)
}
}
@@ -339,7 +339,7 @@ class UploadOrchestrator {
val path = tempUri.path ?: return
val file = File(path)
if (file.delete()) {
Log.d("UploadOrchestrator", "Deleted temp file: $path")
Log.d("UploadOrchestrator") { "Deleted temp file: $path" }
}
} catch (e: Exception) {
Log.w("UploadOrchestrator", "Failed to delete temp file: ${tempUri.path}", e)
@@ -98,7 +98,7 @@ data class CompressionRule(
val codecMultiplier = if (useH265) 0.75f else 1.0f
val finalMultiplier = framerateMultiplier * codecMultiplier
Log.d("VideoCompressionHelper", "framerate: $framerate, useH265: $useH265, Bitrate multiplier: $finalMultiplier")
Log.d("VideoCompressionHelper") { "framerate: $framerate, useH265: $useH265, Bitrate multiplier: $finalMultiplier" }
return (bitrateMbps * finalMultiplier * MBPS_TO_BPS_MULTIPLIER).toInt()
}
@@ -162,13 +162,12 @@ object VideoCompressionHelper {
.getValue(info.resolution.getStandard())
val bitrateBps = rule.getBitrateBps(info.framerate, useH265)
Log.d(LOG_TAG, "Bitrate: ${bitrateBps}bps for ${info.resolution.getStandard()} quality=$mediaQuality framerate=${info.framerate}fps useH265=$useH265.")
Log.d(LOG_TAG) { "Bitrate: ${bitrateBps}bps for ${info.resolution.getStandard()} quality=$mediaQuality framerate=${info.framerate}fps useH265=$useH265." }
Log.d(
LOG_TAG,
Log.d(LOG_TAG) {
"Resizer: ${info.resolution.width}x${info.resolution.height} -> " +
"shortSide=${rule.shortSide} (${rule.description})",
)
"shortSide=${rule.shortSide} (${rule.description})"
}
val resizer = VideoResizer.limitShortSide(rule.shortSide.toDouble())
Pair(bitrateBps, resizer)
@@ -258,11 +257,10 @@ object VideoCompressionHelper {
)
}
Log.d(
LOG_TAG,
Log.d(LOG_TAG) {
"Compression success: Original [$originalSize] -> " +
"Compressed [$size] ($reductionPercent% reduction)",
)
"Compressed [$size] ($reductionPercent% reduction)"
}
if (continuation.isActive) {
continuation.resume(
@@ -60,7 +60,7 @@ class MainActivity : AppCompatActivity() {
enableEdgeToEdge()
super.onCreate(savedInstanceState)
Log.d("ActivityLifecycle", "MainActivity.onCreate $this")
Log.d("ActivityLifecycle") { "MainActivity.onCreate $this" }
setContent {
StringResSetup()
@@ -74,14 +74,14 @@ class MainActivity : AppCompatActivity() {
override fun onResume() {
super.onResume()
Log.d("ActivityLifecycle", "MainActivity.onResume $this")
Log.d("ActivityLifecycle") { "MainActivity.onResume $this" }
// starts muted every time
DEFAULT_MUTED_SETTING.value = true
}
override fun onPause() {
Log.d("ActivityLifecycle", "MainActivity.onPause $this")
Log.d("ActivityLifecycle") { "MainActivity.onPause $this" }
@OptIn(DelicateCoroutinesApi::class)
GlobalScope.launch(Dispatchers.IO) {
@@ -106,11 +106,11 @@ class MainActivity : AppCompatActivity() {
// serviceManager.trimMemory()
// }
Log.d("ActivityLifecycle", "MainActivity.onStop $this")
Log.d("ActivityLifecycle") { "MainActivity.onStop $this" }
}
override fun onDestroy() {
Log.d("ActivityLifecycle", "MainActivity.onDestroy $this")
Log.d("ActivityLifecycle") { "MainActivity.onDestroy $this" }
BackgroundMedia.removeBackgroundControllerAndReleaseIt()
@@ -61,7 +61,7 @@ class VoiceAnonymizationController(
preset: VoicePreset,
originalFile: File?,
) {
Log.d(logTag, "selectPreset called with: ${preset.name}, pitchFactor: ${preset.pitchFactor}")
Log.d(logTag) { "selectPreset called with: ${preset.name}, pitchFactor: ${preset.pitchFactor}" }
if (processingPreset != null || preset == selectedPreset) return
if (preset == VoicePreset.NONE) {
@@ -110,7 +110,7 @@ class VoiceAnonymizationController(
try {
if (result.file.exists()) {
if (result.file.delete()) {
Log.d(logTag, "Deleted distorted file: ${result.file.absolutePath}")
Log.d(logTag) { "Deleted distorted file: ${result.file.absolutePath}" }
} else {
Log.w(logTag, "Failed to delete distorted file: ${result.file.absolutePath}")
}
@@ -176,7 +176,7 @@ class ChannelFeedContentState(
}
fun destroy() {
Log.d("Init", "OnCleared: ${this.javaClass.simpleName}")
Log.d("Init") { "OnCleared: ${this.javaClass.simpleName}" }
bundlerInsert.cancel()
bundler.cancel()
}
@@ -174,5 +174,5 @@ private fun speak(
.speak(message)
.highlight()
.onDone { Log.d("TextToSpeak", "speak: done") }
.onError { Log.d("TextToSpeak", "speak error: $it") }
.onError { Log.d("TextToSpeak") { "speak error: $it" } }
}
@@ -48,7 +48,7 @@ fun AccountScreen(accountSessionManager: AccountSessionManager) {
val accountState by accountSessionManager.accountContent.collectAsStateWithLifecycle()
Log.d("ActivityLifecycle", "AccountScreen $accountState $accountSessionManager")
Log.d("ActivityLifecycle") { "AccountScreen $accountState $accountSessionManager" }
Crossfade(
targetState = accountState,
@@ -238,7 +238,7 @@ class TopNavFilterState(
.stateIn(scope, SharingStarted.Eagerly, defaultLists)
fun destroy() {
Log.d("Init", "OnCleared: ${this.javaClass.simpleName}")
Log.d("Init") { "OnCleared: ${this.javaClass.simpleName}" }
}
}
@@ -99,24 +99,24 @@ open class UserFeedViewModel(
}
init {
Log.d("Init", "${this.javaClass.simpleName}")
Log.d("Init") { "${this.javaClass.simpleName}" }
viewModelScope.launch(Dispatchers.IO) {
LocalCache.live.newEventBundles.collect { newNotes ->
Log.d("Rendering Metrics", "Update feeds: ${this@UserFeedViewModel.javaClass.simpleName} with ${newNotes.size}")
Log.d("Rendering Metrics") { "Update feeds: ${this@UserFeedViewModel.javaClass.simpleName} with ${newNotes.size}" }
invalidateData()
}
}
viewModelScope.launch(Dispatchers.IO) {
LocalCache.live.deletedEventBundles.collect { newNotes ->
Log.d("Rendering Metrics", "Delete from feeds: ${this@UserFeedViewModel.javaClass.simpleName} with ${newNotes.size}")
Log.d("Rendering Metrics") { "Delete from feeds: ${this@UserFeedViewModel.javaClass.simpleName} with ${newNotes.size}" }
invalidateData()
}
}
}
override fun onCleared() {
Log.d("Init", "OnCleared: ${this.javaClass.simpleName}")
Log.d("Init") { "OnCleared: ${this.javaClass.simpleName}" }
bundler.cancel()
super.onCleared()
}
@@ -801,7 +801,7 @@ class ChatNewMessageViewModel :
override fun onCleared() {
super.onCleared()
Log.d("Init", "OnCleared: ${this.javaClass.simpleName}")
Log.d("Init") { "OnCleared: ${this.javaClass.simpleName}" }
}
// NIP-04 sending is deprecated. NIP-17 is always used.
@@ -663,7 +663,7 @@ open class ChannelNewMessageViewModel :
override fun onCleared() {
super.onCleared()
Log.d("Init", "OnCleared: ${this.javaClass.simpleName}")
Log.d("Init") { "OnCleared: ${this.javaClass.simpleName}" }
}
fun updateZapPercentage(
@@ -687,7 +687,7 @@ class LongFormPostViewModel :
override fun onCleared() {
super.onCleared()
Log.d("Init", "OnCleared: ${this.javaClass.simpleName}")
Log.d("Init") { "OnCleared: ${this.javaClass.simpleName}" }
}
override fun updateZapPercentage(
@@ -608,7 +608,7 @@ open class NewProductViewModel :
override fun onCleared() {
super.onCleared()
Log.d("Init", "OnCleared: ${this.javaClass.simpleName}")
Log.d("Init") { "OnCleared: ${this.javaClass.simpleName}" }
}
override fun updateZapPercentage(
@@ -1271,7 +1271,7 @@ open class ShortNotePostViewModel :
voiceLocalFile?.let { file ->
try {
if (file.delete()) {
Log.d("ShortNotePostViewModel", "Deleted voice file: ${file.absolutePath}")
Log.d("ShortNotePostViewModel") { "Deleted voice file: ${file.absolutePath}" }
}
} catch (e: Exception) {
Log.w("ShortNotePostViewModel", "Failed to delete voice file: ${file.absolutePath}", e)
@@ -1365,7 +1365,7 @@ open class ShortNotePostViewModel :
override fun onCleared() {
super.onCleared()
Log.d("Init", "OnCleared: ${this.javaClass.simpleName}")
Log.d("Init") { "OnCleared: ${this.javaClass.simpleName}" }
}
override fun updateZapPercentage(
@@ -157,7 +157,7 @@ class VoiceReplyViewModel : ViewModel() {
try {
if (file.exists()) {
file.delete()
Log.d("VoiceReplyViewModel", "Deleted voice file: ${file.absolutePath}")
Log.d("VoiceReplyViewModel") { "Deleted voice file: ${file.absolutePath}" }
}
} catch (e: Exception) {
Log.w("VoiceReplyViewModel", "Failed to delete voice file: ${file.absolutePath}", e)
@@ -315,6 +315,6 @@ class VoiceReplyViewModel : ViewModel() {
override fun onCleared() {
cancel()
super.onCleared()
Log.d("Init", "OnCleared: ${this.javaClass.simpleName}")
Log.d("Init") { "OnCleared: ${this.javaClass.simpleName}" }
}
}
@@ -106,7 +106,7 @@ private suspend fun checkChannelIsOnline(
}
}
} catch (e: Exception) {
Log.d("LiveStatusIndicator", "Network error checking channel ${channel.toBestDisplayName()}: ${e.message}")
Log.d("LiveStatusIndicator") { "Network error checking channel ${channel.toBestDisplayName()}: ${e.message}" }
// Return false if any network error occurs
false
}
@@ -463,7 +463,7 @@ class CardFeedContentState(
}
fun destroy() {
Log.d("Init", "OnCleared: ${this.javaClass.simpleName}")
Log.d("Init") { "OnCleared: ${this.javaClass.simpleName}" }
clear()
bundlerInsert.cancel()
bundler.cancel()
@@ -271,6 +271,6 @@ class NotificationSummaryState(
fun destroy() {
bundlerInsert.cancel()
Log.d("Init", "OnCleared: ${this.javaClass.simpleName}")
Log.d("Init") { "OnCleared: ${this.javaClass.simpleName}" }
}
}
@@ -657,7 +657,7 @@ class NewPublicMessageViewModel :
override fun onCleared() {
super.onCleared()
Log.d("Init", "OnCleared: ${this.javaClass.simpleName}")
Log.d("Init") { "OnCleared: ${this.javaClass.simpleName}" }
}
override fun updateZapPercentage(
@@ -195,7 +195,7 @@ class RelayFeedViewModel :
}
override fun onCleared() {
Log.d("Init", "OnCleared: ${this.javaClass.simpleName}")
Log.d("Init") { "OnCleared: ${this.javaClass.simpleName}" }
super.onCleared()
}
}
@@ -101,20 +101,20 @@ open class StringFeedViewModel(
Log.d("Init", this.javaClass.simpleName)
viewModelScope.launch(Dispatchers.IO) {
LocalCache.live.newEventBundles.collect { newNotes ->
Log.d("Rendering Metrics", "Update feeds: ${this@StringFeedViewModel.javaClass.simpleName} with ${newNotes.size}")
Log.d("Rendering Metrics") { "Update feeds: ${this@StringFeedViewModel.javaClass.simpleName} with ${newNotes.size}" }
invalidateData()
}
}
viewModelScope.launch(Dispatchers.IO) {
LocalCache.live.deletedEventBundles.collect { newNotes ->
Log.d("Rendering Metrics", "Delete feeds: ${this@StringFeedViewModel.javaClass.simpleName} with ${newNotes.size}")
Log.d("Rendering Metrics") { "Delete feeds: ${this@StringFeedViewModel.javaClass.simpleName} with ${newNotes.size}" }
invalidateData()
}
}
}
override fun onCleared() {
Log.d("Init", "OnCleared: ${this.javaClass.simpleName}")
Log.d("Init") { "OnCleared: ${this.javaClass.simpleName}" }
bundler.cancel()
super.onCleared()
}
@@ -65,7 +65,7 @@ class TorService(
active.torControlConnection = torService.torControlConnection
trySend(active)
Log.d("TorService", "Tor Service Connected ${torService.socksPort}")
Log.d("TorService") { "Tor Service Connected ${torService.socksPort}" }
}
}
@@ -86,7 +86,7 @@ class TorService(
try {
context.unbindService(serviceConnection)
} catch (e: Exception) {
Log.d("TorService", "Failed to unbind Tor Service: ${e.message}")
Log.d("TorService") { "Failed to unbind Tor Service: ${e.message}" }
}
launch {
context.stopService(currentIntent)
@@ -49,7 +49,7 @@ class PushNotificationReceiverService : FirebaseMessagingService() {
// this is called when a message is received
override fun onMessageReceived(remoteMessage: RemoteMessage) {
Log.d("PushNotificationService", "Notification received $remoteMessage")
Log.d("PushNotificationService") { "Notification received $remoteMessage" }
scope.launch(Dispatchers.IO) {
parseMessage(remoteMessage.data)?.let { receiveIfNew(it) }
}
@@ -124,7 +124,7 @@ class EphemeralChatListState(
scope.launch(Dispatchers.IO) {
Log.d("AccountRegisterObservers", "EphemeralChatList Collector Start")
getEphemeralChatListFlow().collect { noteState ->
Log.d("AccountRegisterObservers", "EphemeralChatList List for ${signer.pubKey}")
Log.d("AccountRegisterObservers") { "EphemeralChatList List for ${signer.pubKey}" }
(noteState.note.event as? EphemeralChatListEvent)?.let {
settings.updateEphemeralChatListTo(it)
}
@@ -161,7 +161,7 @@ class Kind3FollowListState(
init {
settings.backupContactList?.let {
Log.d("AccountRegisterObservers", "Loading saved ${it.tags.size} contacts")
Log.d("AccountRegisterObservers") { "Loading saved ${it.tags.size} contacts" }
@OptIn(DelicateCoroutinesApi::class)
scope.launch(Dispatchers.IO) { cache.justConsumeMyOwnEvent(it) }
@@ -171,7 +171,7 @@ class Kind3FollowListState(
scope.launch(Dispatchers.IO) {
Log.d("AccountRegisterObservers", "Kind 3 Collector Start")
getFollowListFlow().collect {
Log.d("AccountRegisterObservers", "Updating Kind 3 ${signer.pubKey}")
Log.d("AccountRegisterObservers") { "Updating Kind 3 ${signer.pubKey}" }
(it.note.event as? ContactListEvent)?.let {
settings.updateContactListTo(it)
}
@@ -129,7 +129,7 @@ class PublicChatListState(
init {
settings.channelList()?.let { event ->
Log.d("AccountRegisterObservers", "Loading saved channel list ${event.toJson()}")
Log.d("AccountRegisterObservers") { "Loading saved channel list ${event.toJson()}" }
@OptIn(DelicateCoroutinesApi::class)
scope.launch(Dispatchers.IO) {
cache.justConsumeMyOwnEvent(event)
@@ -139,7 +139,7 @@ class PublicChatListState(
scope.launch(Dispatchers.IO) {
Log.d("AccountRegisterObservers", "Channel List Collector Start")
getChannelListFlow().collect {
Log.d("AccountRegisterObservers", "Channel List for ${signer.pubKey}")
Log.d("AccountRegisterObservers") { "Channel List for ${signer.pubKey}" }
(it.note.event as? ChannelListEvent)?.let {
settings.updateChannelListTo(it)
}
@@ -142,7 +142,7 @@ class Nip65RelayListState(
init {
settings.backupNIP65RelayList?.let {
Log.d("AccountRegisterObservers", "Loading saved nip65 relay list ${it.toJson()}")
Log.d("AccountRegisterObservers") { "Loading saved nip65 relay list ${it.toJson()}" }
@OptIn(DelicateCoroutinesApi::class)
scope.launch(Dispatchers.IO) { cache.justConsumeMyOwnEvent(it) }
}
@@ -150,7 +150,7 @@ class Nip65RelayListState(
scope.launch(Dispatchers.IO) {
Log.d("AccountRegisterObservers", "NIP-65 Relay List Collector Start")
getNIP65RelayListFlow().collect {
Log.d("AccountRegisterObservers", "Updating NIP-65 List for ${signer.pubKey}")
Log.d("AccountRegisterObservers") { "Updating NIP-65 List for ${signer.pubKey}" }
(it.note.event as? AdvertisedRelayListEvent)?.let {
settings.updateNIP65RelayList(it)
}
@@ -39,7 +39,7 @@ inline fun <T> logTime(
if (isDebug) {
val (result, elapsed) = measureTimedValue(block)
if (elapsed.inWholeMilliseconds > minToReportMs) {
Log.d("DEBUG-TIME", "${elapsed.toString(DurationUnit.MILLISECONDS, 3).padStart(12)}: $debugMessage")
Log.d("DEBUG-TIME") { "${elapsed.toString(DurationUnit.MILLISECONDS, 3).padStart(12)}: $debugMessage" }
}
result
} else {
@@ -54,7 +54,7 @@ inline fun <T> logTime(
if (isDebug) {
val (result, elapsed) = measureTimedValue(block)
if (elapsed.inWholeMilliseconds > minToReportMs) {
Log.d("DEBUG-TIME", "${elapsed.toString(DurationUnit.MILLISECONDS, 3).padStart(12)}: ${debugMessage(result)}")
Log.d("DEBUG-TIME") { "${elapsed.toString(DurationUnit.MILLISECONDS, 3).padStart(12)}: ${debugMessage(result)}" }
}
result
} else {
@@ -49,24 +49,24 @@ abstract class FeedViewModel(
override fun invalidateData(ignoreIfDoing: Boolean) = feedState.invalidateData(ignoreIfDoing)
init {
Log.d("Init", "Starting new Model: ${this::class.simpleName}")
Log.d("Init") { "Starting new Model: ${this::class.simpleName}" }
viewModelScope.launch(Dispatchers.IO) {
cacheProvider.getEventStream().newEventBundles.collect { newNotes ->
Log.d("Rendering Metrics", "Update feeds: ${this@FeedViewModel::class.simpleName} with ${newNotes.size}")
Log.d("Rendering Metrics") { "Update feeds: ${this@FeedViewModel::class.simpleName} with ${newNotes.size}" }
feedState.updateFeedWith(newNotes)
}
}
viewModelScope.launch(Dispatchers.IO) {
cacheProvider.getEventStream().deletedEventBundles.collect { newNotes ->
Log.d("Rendering Metrics", "Delete from feeds: ${this@FeedViewModel::class.simpleName} with ${newNotes.size}")
Log.d("Rendering Metrics") { "Delete from feeds: ${this@FeedViewModel::class.simpleName} with ${newNotes.size}" }
feedState.deleteFromFeed(newNotes)
}
}
}
override fun onCleared() {
Log.d("Init", "OnCleared: ${this::class.simpleName}")
Log.d("Init") { "OnCleared: ${this::class.simpleName}" }
super.onCleared()
}
}
@@ -46,14 +46,14 @@ abstract class ListChangeFeedViewModel(
override fun invalidateData(ignoreIfDoing: Boolean) = feedState.invalidateData(ignoreIfDoing)
init {
Log.d("Init", "Starting new Model: ${this::class.simpleName}")
Log.d("Init") { "Starting new Model: ${this::class.simpleName}" }
// Trigger initial load so empty rooms show Empty instead of Loading
viewModelScope.launch(Dispatchers.IO) {
feedState.invalidateData(ignoreIfDoing = false)
}
viewModelScope.launch(Dispatchers.IO) {
localFilter.changesFlow().collect {
Log.d("Init", "Collecting changes to: ${this@ListChangeFeedViewModel::class.simpleName}")
Log.d("Init") { "Collecting changes to: ${this@ListChangeFeedViewModel::class.simpleName}" }
when (it) {
is ListChange.Addition -> feedState.updateFeedWith(setOf(it.item))
is ListChange.Deletion -> feedState.deleteFromFeed(setOf(it.item))
@@ -59,7 +59,7 @@ suspend fun INostrClient.publishAndConfirmDetailed(
): Map<NormalizedRelayUrl, Boolean> {
val resultChannel = Channel<Result>(UNLIMITED)
Log.d("publishAndConfirm", "Waiting for ${relayList.size} responses")
Log.d("publishAndConfirm") { "Waiting for ${relayList.size} responses" }
val subscription =
object : RelayConnectionListener {
@@ -69,14 +69,14 @@ suspend fun INostrClient.publishAndConfirmDetailed(
) {
if (relay.url in relayList) {
resultChannel.trySend(Result(relay.url, false))
Log.d("publishAndConfirm", "Error from relay ${relay.url}: $errorMessage")
Log.d("publishAndConfirm") { "Error from relay ${relay.url}: $errorMessage" }
}
}
override fun onDisconnected(relay: IRelayClient) {
if (relay.url in relayList) {
resultChannel.trySend(Result(relay.url, false))
Log.d("publishAndConfirm", "Disconnected from relay ${relay.url}")
Log.d("publishAndConfirm") { "Disconnected from relay ${relay.url}" }
}
}
@@ -91,7 +91,7 @@ suspend fun INostrClient.publishAndConfirmDetailed(
is OkMessage -> {
if (msg.eventId == event.id) {
resultChannel.trySend(Result(relay.url, msg.success))
Log.d("publishAndConfirm", "onSendResponse Received response for ${msg.eventId} from relay ${relay.url} message ${msg.message} success ${msg.success}")
Log.d("publishAndConfirm") { "onSendResponse Received response for ${msg.eventId} from relay ${relay.url} message ${msg.message} success ${msg.success}" }
}
}
}
@@ -136,7 +136,7 @@ suspend fun INostrClient.publishAndConfirmDetailed(
// Clean up the channel
resultChannel.close()
Log.d("publishAndConfirm", "Finished with ${receivedResults.size} results")
Log.d("publishAndConfirm") { "Finished with ${receivedResults.size} results" }
return receivedResults
}
@@ -57,13 +57,13 @@ class RelayLogger(
val logTag = logTag(relay.url)
when (msg) {
is EventMessage -> if (debugReceiving) Log.d(logTag, "Received: $msgStr")
is EoseMessage -> if (debugReceiving) Log.d(logTag, "EOSE: ${msg.subId}")
is EventMessage -> if (debugReceiving) Log.d(logTag) { "Received: $msgStr" }
is EoseMessage -> if (debugReceiving) Log.d(logTag) { "EOSE: ${msg.subId}" }
is NoticeMessage -> Log.w(logTag, "Notice: ${msg.message}")
is OkMessage -> if (debugReceiving) Log.d(logTag, "OK: ${msg.eventId} ${msg.success} ${msg.message}")
is AuthMessage -> if (debugReceiving) Log.d(logTag, "Auth: ${msg.challenge}")
is NotifyMessage -> if (debugReceiving) Log.d(logTag, "Notify: ${msg.message}")
is CountMessage -> if (debugReceiving) Log.d(logTag, "Count: ${msg.result.count} approx: ${msg.result.approximate} hll: ${msg.result.hll != null}")
is OkMessage -> if (debugReceiving) Log.d(logTag) { "OK: ${msg.eventId} ${msg.success} ${msg.message}" }
is AuthMessage -> if (debugReceiving) Log.d(logTag) { "Auth: ${msg.challenge}" }
is NotifyMessage -> if (debugReceiving) Log.d(logTag) { "Notify: ${msg.message}" }
is CountMessage -> if (debugReceiving) Log.d(logTag) { "Count: ${msg.result.count} approx: ${msg.result.approximate} hll: ${msg.result.hll != null}" }
is ClosedMessage -> Log.w(logTag, "Closed: ${msg.subId} ${msg.message}")
}
}
@@ -76,7 +76,7 @@ class RelayLogger(
) {
if (success) {
if (debugSending) {
Log.d(logTag(relay.url), "Sent (${cmdStr.length} chars): $cmdStr")
Log.d(logTag(relay.url)) { "Sent (${cmdStr.length} chars): $cmdStr" }
}
} else {
Log.e(logTag(relay.url), "Failure sending (${cmdStr.length} chars): $cmdStr")
@@ -92,7 +92,7 @@ class RelayLogger(
pingMillis: Int,
compressed: Boolean,
) {
Log.d(logTag(relay.url), "OnOpen (ping: ${pingMillis}ms${if (compressed) ", using compression" else ""})")
Log.d(logTag(relay.url)) { "OnOpen (ping: ${pingMillis}ms${if (compressed) ", using compression" else ""})" }
}
override fun onDisconnected(relay: IRelayClient) {
@@ -51,7 +51,7 @@ class RelayReqStats(
fun printStats() =
stats.printCounter { subId, kind, counter ->
Log.d("RelaySubStats", "$subId, kind $kind: $counter")
Log.d("RelaySubStats") { "$subId, kind $kind: $counter" }
}
init {
@@ -60,7 +60,7 @@ class OkHttpBitcoinExplorer(
return client.newCall(request).execute().use {
if (it.isSuccessful) {
Log.d("OkHttpBlockstreamExplorer", "$baseAPI/block/$hash")
Log.d("OkHttpBlockstreamExplorer") { "$baseAPI/block/$hash" }
val jsonObject = JacksonMapper.mapper.readTree(it.body.string())
@@ -104,7 +104,7 @@ class OkHttpBitcoinExplorer(
if (it.isSuccessful) {
val blockHash = it.body.string()
Log.d("OkHttpBlockstreamExplorer", "$url $blockHash")
Log.d("OkHttpBlockstreamExplorer") { "$url $blockHash" }
cache.putHeight(height, blockHash)
blockHash
@@ -60,7 +60,7 @@ class NostrClientRepeatSubTest : BaseNostrClientTest() {
msgStr: String,
msg: Message,
) {
Log.d("Test", "Receiving message: $msgStr")
Log.d("Test") { "Receiving message: $msgStr" }
when (msg) {
is EventMessage -> {
if (mySubId == msg.subId) {
@@ -116,7 +116,7 @@ class NostrClientRepeatSubTest : BaseNostrClientTest() {
launch {
withTimeoutOrNull(30000) {
while (events.size < 112) {
Log.d("Test", "Processing message ${events.size}")
Log.d("Test") { "Processing message ${events.size}" }
// simulates an update in the middle of the sub
if (events.size == 1) {
client.subscribe(mySubId, filtersShouldIgnore)
@@ -64,7 +64,7 @@ class NostrClientSubscriptionAsFlowTest : BaseNostrClientTest() {
val job =
launch {
flow.collect {
Log.d("ZZ", "List timestamp deltas ${it.printDates()}")
Log.d("ZZ") { "List timestamp deltas ${it.printDates()}" }
feedStates = it
}
}
@@ -103,7 +103,7 @@ class NostrClientSubscriptionAsFlowTest : BaseNostrClientTest() {
val job =
launch {
flow.debounce(100).collect {
Log.d("ZZ", "List timestamp deltas ${it.printDates()}")
Log.d("ZZ") { "List timestamp deltas ${it.printDates()}" }
feedStates = it
}
}
@@ -64,7 +64,7 @@ class NostrClientSubscriptionUntilEoseAsFlowTest : BaseNostrClientTest() {
val job =
launch {
flow.collect {
Log.d("ZZ", "List timestamp deltas ${it.printDates()}")
Log.d("ZZ") { "List timestamp deltas ${it.printDates()}" }
feedStates = it
}
}
@@ -103,7 +103,7 @@ class NostrClientSubscriptionUntilEoseAsFlowTest : BaseNostrClientTest() {
val job =
launch {
flow.debounce(100).collect {
Log.d("ZZ", "List timestamp deltas ${it.printDates()}")
Log.d("ZZ") { "List timestamp deltas ${it.printDates()}" }
feedStates = it
}
}