Skip to content

Commit f0d1ca2

Browse files
authored
disable default log (#119)
1 parent 1696c9b commit f0d1ca2

File tree

6 files changed

+17
-12
lines changed

6 files changed

+17
-12
lines changed

deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@blowater/nostr-sdk",
3-
"version": "0.1.2",
3+
"version": "0.1.3",
44
"exports": "./nostr.ts",
55
"fmt": {
66
"indentWidth": 4,

nip9-test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import { assertEquals, fail } from "@std/assert";
22
import { prepareDeletionEvent, prepareNostrEvent } from "./event.ts";
3-
import { InMemoryAccountContext, NostrKind } from "./nostr.ts";
3+
import { InMemoryAccountContext, NostrEvent, NostrKind } from "./nostr.ts";
44
import { SingleRelayConnection } from "./relay-single.ts";
55

66
export const store_deletion_event = (url: string) => async () => {
7-
const relay = SingleRelayConnection.New(url, { log: true }) as SingleRelayConnection;
7+
const relay = SingleRelayConnection.New(url) as SingleRelayConnection;
88
const ctx = InMemoryAccountContext.Generate();
99
try {
1010
const event = await prepareNostrEvent(ctx, {
1111
content: "test send_deletion_event",
1212
kind: NostrKind.TEXT_NOTE,
13-
});
13+
}) as NostrEvent;
1414
const deletion = await prepareDeletionEvent(ctx, "test deletion", event);
1515
if (deletion instanceof Error) {
1616
fail(deletion.message);
@@ -26,15 +26,15 @@ export const store_deletion_event = (url: string) => async () => {
2626
};
2727

2828
export const delete_regular_events = (url: string) => async () => {
29-
const relay = SingleRelayConnection.New(url, { log: true }) as SingleRelayConnection;
29+
const relay = SingleRelayConnection.New(url) as SingleRelayConnection;
3030
const ctx = InMemoryAccountContext.Generate();
3131
const testkind = [NostrKind.TEXT_NOTE, NostrKind.DIRECT_MESSAGE];
3232
try {
3333
for (const kind of testkind) {
3434
const event = await prepareNostrEvent(ctx, {
3535
content: "test send_deletion_event",
3636
kind,
37-
});
37+
}) as NostrEvent;
3838
const err1 = await relay.sendEvent(event);
3939
if (err1 instanceof Error) fail(err1.message);
4040

relay-pool.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ export class ConnectionPool
101101
}
102102
const client = SingleRelayConnection.New(url.toString(), {
103103
wsCreator: this.wsCreator,
104-
log: true,
105104
signer: this.args?.signer,
106105
signer_v2: this.args?.signer_v2,
107106
}) as SingleRelayConnection;

relay-single.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export class SingleRelayConnection implements Subscriber, SubscriptionCloser, Ev
141141
if (messsage.type == "RelayDisconnectedByClient") {
142142
this.error = messsage.error;
143143
// exit the coroutine
144-
return messsage.error
144+
return messsage.error;
145145
} else if (
146146
messsage.type == "WebSocketClosed" ||
147147
messsage.type == "FailedToLookupAddress" ||
@@ -262,7 +262,9 @@ export class SingleRelayConnection implements Subscriber, SubscriptionCloser, Ev
262262
}
263263
})().then((res) => {
264264
if (res instanceof RelayDisconnectedByClient) {
265-
console.log(res);
265+
if (this.log) {
266+
console.log(res);
267+
}
266268
return;
267269
}
268270
if (res instanceof Error) {

tests/relay-single-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ export const two_clients_communicate = (url: string) => async () => {
245245
};
246246

247247
export const get_event_by_id = (url: string) => async () => {
248-
const client = SingleRelayConnection.New(url, { log: true }) as SingleRelayConnection;
248+
const client = SingleRelayConnection.New(url) as SingleRelayConnection;
249249
const ctx = InMemoryAccountContext.Generate();
250250
{
251251
const event_1 = await client.getEvent(PrivateKey.Generate().hex);

websocket.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,16 @@ export class AsyncWebSocket implements BidirectionalNetwork {
167167

168168
this.ws.close(code, reason);
169169

170-
console.log(this.status(), this.url.host + this.url.pathname);
170+
if (this.log) {
171+
console.log(this.status(), this.url.host + this.url.pathname);
172+
}
171173
if (force) {
172174
return;
173175
}
174176
await this.onClose.pop();
175-
console.log(this.status(), this.url.host + this.url.pathname, this.closedEvent);
177+
if (this.log) {
178+
console.log(this.status(), this.url.host + this.url.pathname, this.closedEvent);
179+
}
176180
return this.closedEvent;
177181
}
178182

0 commit comments

Comments
 (0)