Fixing log messages
This commit is contained in:
@@ -74,7 +74,7 @@ class AntiSpamFilter {
|
||||
) {
|
||||
Log.w(
|
||||
"Potential SPAM Message",
|
||||
"${event.id} ${recentMessages[hash]} ${spamMessages[hash] != null} $relay ${event.content.replace("\n", " | ")}",
|
||||
"${event.id} ${recentMessages[hash]} ${spamMessages[hash] != null} ${relay?.url} ${event.content.replace("\n", " | ")}",
|
||||
)
|
||||
|
||||
// Log down offenders
|
||||
|
||||
@@ -2947,7 +2947,7 @@ object LocalCache : ILocalCache {
|
||||
// update relay with deletion event from another.
|
||||
if (relay != null) {
|
||||
deletionIndex.hasBeenDeletedBy(event)?.let {
|
||||
Log.d("LocalCache", "Updating ${relay.url} with a Deletion Event ${it.toJson()} because of ${event.toJson()}")
|
||||
Log.d("LocalCache", "Updating ${relay.url.url} with a Deletion Event ${it.toJson()} because of ${event.toJson()}")
|
||||
relay.send(it)
|
||||
}
|
||||
}
|
||||
@@ -2959,7 +2959,7 @@ object LocalCache : ILocalCache {
|
||||
getAddressableNoteIfExists(event.addressTag())?.let { note ->
|
||||
note.event?.let { existingEvent ->
|
||||
if (existingEvent.createdAt > event.createdAt && !note.hasRelay(relay.url)) {
|
||||
Log.d("LocalCache", "Updating ${relay.url} with a new version of ${event.toJson()} to ${existingEvent.toJson()}")
|
||||
Log.d("LocalCache", "Updating ${relay.url.url} with a new version of ${event.toJson()} to ${existingEvent.toJson()}")
|
||||
relay.send(existingEvent)
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -102,15 +102,15 @@ class RegisterAccounts(
|
||||
if (acc != null && acc.isWriteable()) {
|
||||
val nip65Read = acc.backupNIP65RelayList?.readRelaysNorm() ?: emptyList()
|
||||
|
||||
Log.d(tag, "Register Account ${it.npub} NIP65 Reads ${nip65Read.joinToString(", ")}")
|
||||
Log.d(tag, "Register Account ${it.npub} NIP65 Reads ${nip65Read.joinToString(", ") { it.url } }")
|
||||
|
||||
val nip17Read = acc.backupDMRelayList?.relays() ?: emptyList()
|
||||
|
||||
Log.d(tag, "Register Account ${it.npub} NIP17 Reads ${nip17Read.joinToString(", ")}")
|
||||
Log.d(tag, "Register Account ${it.npub} NIP17 Reads ${nip17Read.joinToString(", ") { it.url } }")
|
||||
|
||||
val readKind3Relays = acc.backupContactList?.relays()?.mapNotNull { if (it.value.read) it.key else null } ?: emptyList()
|
||||
|
||||
Log.d(tag, "Register Account ${it.npub} Kind3 Reads ${readKind3Relays.joinToString(", ")}")
|
||||
Log.d(tag, "Register Account ${it.npub} Kind3 Reads ${readKind3Relays.joinToString(", ") { it.url } }")
|
||||
|
||||
val relays = (nip65Read + nip17Read + readKind3Relays)
|
||||
|
||||
|
||||
@@ -72,32 +72,6 @@ class NostrClient(
|
||||
activeSubscriptions.relays.value + eventOutbox.relays.value
|
||||
}.onEach {
|
||||
relayPool.updatePool(it)
|
||||
|
||||
val subs = activeSubscriptions.allSubscriptions()
|
||||
|
||||
it.forEach { relay ->
|
||||
var hasSub = false
|
||||
subs.forEach { sub ->
|
||||
sub.value.filters.forEach {
|
||||
if (it.isValidFor(relay)) {
|
||||
hasSub = true
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!hasSub) {
|
||||
Log.d("NostrClient", "AABBCC $relay doesn't have any sub")
|
||||
}
|
||||
|
||||
if (relayPool.getRelay(relay)?.isConnected() == false) {
|
||||
Log.d("NostrClient", "AABBCC $relay is not connected")
|
||||
}
|
||||
}
|
||||
|
||||
val filters = subs.values.sumOf { it.filters.size }
|
||||
Log.d("NostrClient", "Updating list for relays to ${it.size} relays and ${subs.size} subscriptions and $filters filters")
|
||||
it.forEach {
|
||||
Log.d("NostrClient", "${it.url} isConnected ${relayPool.getRelay(it)?.isConnected()}")
|
||||
}
|
||||
}.flowOn(Dispatchers.Default)
|
||||
.stateIn(
|
||||
scope,
|
||||
|
||||
+10
-10
@@ -98,8 +98,6 @@ open class BasicRelayClient(
|
||||
}
|
||||
|
||||
fun connectAndRunOverride(onConnected: () -> Unit) {
|
||||
Log.d("Relay", "Relay.connect $url isAlreadyConnecting: ${connectingMutex.get()}")
|
||||
|
||||
// If there is a connection, don't wait.
|
||||
if (connectingMutex.getAndSet(true)) {
|
||||
return
|
||||
@@ -111,6 +109,8 @@ open class BasicRelayClient(
|
||||
return
|
||||
}
|
||||
|
||||
Log.d("Relay", "${url.url} connecting...")
|
||||
|
||||
lastConnectTentative = TimeUtils.now()
|
||||
|
||||
socket = socketBuilder.build(url, MyWebsocketListener(onConnected))
|
||||
@@ -118,7 +118,7 @@ open class BasicRelayClient(
|
||||
} catch (e: Exception) {
|
||||
if (e is CancellationException) throw e
|
||||
|
||||
Log.w("Relay", "Relay Crash before connedting $url", e)
|
||||
Log.w("Relay", "${url.url} Crash before connecting $url", e)
|
||||
stats.newError(e.message ?: "Error trying to connect: ${e.javaClass.simpleName}")
|
||||
|
||||
markConnectionAsClosed()
|
||||
@@ -135,7 +135,7 @@ open class BasicRelayClient(
|
||||
pingMillis: Long,
|
||||
compression: Boolean,
|
||||
) {
|
||||
Log.d("Relay", "Connect onOpen $url $socket")
|
||||
Log.d("Relay", "${url.url} onConnect $socket")
|
||||
|
||||
markConnectionAsReady(pingMillis, compression)
|
||||
|
||||
@@ -161,7 +161,7 @@ open class BasicRelayClient(
|
||||
} catch (e: Throwable) {
|
||||
if (e is CancellationException) throw e
|
||||
stats.newError("Error processing: $text")
|
||||
Log.e("Relay", "Error processing: $text from ${url.url}")
|
||||
Log.e("Relay", "${url.url} Error processing: $text")
|
||||
listener.onError(this@BasicRelayClient, "", Error("Error processing $text"))
|
||||
}
|
||||
}
|
||||
@@ -170,7 +170,7 @@ open class BasicRelayClient(
|
||||
code: Int,
|
||||
reason: String,
|
||||
) {
|
||||
Log.w("Relay", "Relay onClosing $url: $reason")
|
||||
Log.w("Relay", "${url.url} onClosing: $code $reason")
|
||||
|
||||
listener.onRelayStateChange(this@BasicRelayClient, RelayState.DISCONNECTING)
|
||||
}
|
||||
@@ -181,7 +181,7 @@ open class BasicRelayClient(
|
||||
) {
|
||||
markConnectionAsClosed()
|
||||
|
||||
Log.w("Relay", "Relay onClosed $url: $reason")
|
||||
Log.w("Relay", "${url.url} onClosed $reason")
|
||||
|
||||
listener.onRelayStateChange(this@BasicRelayClient, RelayState.DISCONNECTED)
|
||||
}
|
||||
@@ -201,7 +201,7 @@ open class BasicRelayClient(
|
||||
// Failures disconnect the relay.
|
||||
markConnectionAsClosed()
|
||||
|
||||
Log.w("Relay", "Relay onFailure $url, $code $response ${t.message} $socket")
|
||||
Log.w("Relay", "${url.url} onFailure $code $response ${t.message} $socket")
|
||||
t.printStackTrace()
|
||||
listener.onError(
|
||||
this@BasicRelayClient,
|
||||
@@ -258,7 +258,7 @@ open class BasicRelayClient(
|
||||
msg: OkMessage,
|
||||
onConnected: () -> Unit,
|
||||
) {
|
||||
Log.w("Relay", "Relay on OK $url, ${msg.eventId} ${msg.success} ${msg.message}")
|
||||
Log.w("Relay", "${url.url} Relay on OK: ${msg.eventId} ${msg.success} ${msg.message}")
|
||||
|
||||
// if this is the OK of an auth event, renew all subscriptions and resend all outgoing events.
|
||||
if (authResponseWatcher.containsKey(msg.eventId)) {
|
||||
@@ -300,7 +300,7 @@ open class BasicRelayClient(
|
||||
}
|
||||
|
||||
override fun disconnect() {
|
||||
Log.d("Relay", "Relay.disconnect $url")
|
||||
Log.d("Relay", "${url.url} disconnecting...")
|
||||
lastConnectTentative = 0L // this is not an error, so prepare to reconnect as soon as requested.
|
||||
delayToConnect = DELAY_TO_RECONNECT_IN_MSECS
|
||||
socket?.disconnect()
|
||||
|
||||
Reference in New Issue
Block a user