From 6f4728c447859db17aaee613060b67271922fc2a Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Fri, 10 Nov 2023 18:26:53 +0100 Subject: [PATCH] fix: add logger field (#234) This will be ignored by pre v1 versions --- packages/libp2p-daemon-client/src/index.ts | 7 +++++-- packages/libp2p-daemon-server/src/index.ts | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/libp2p-daemon-client/src/index.ts b/packages/libp2p-daemon-client/src/index.ts index 58d82542..e8e80253 100644 --- a/packages/libp2p-daemon-client/src/index.ts +++ b/packages/libp2p-daemon-client/src/index.ts @@ -3,7 +3,7 @@ import { StreamHandler } from '@libp2p/daemon-protocol/stream-handler' import { passThroughUpgrader } from '@libp2p/daemon-protocol/upgrader' import { CodeError } from '@libp2p/interface/errors' import { isPeerId, type PeerId } from '@libp2p/interface/peer-id' -import { logger } from '@libp2p/logger' +import { defaultLogger, logger } from '@libp2p/logger' import { peerIdFromBytes } from '@libp2p/peer-id' import { tcp } from '@libp2p/tcp' import { multiaddr, isMultiaddr } from '@multiformats/multiaddr' @@ -27,7 +27,10 @@ class Client implements DaemonClient { constructor (addr: Multiaddr) { this.multiaddr = addr - this.tcp = tcp()() + this.tcp = tcp()({ + // @ts-expect-error this field will be present post v1 + logger: defaultLogger() + }) this.dht = new DHT(this) this.pubsub = new Pubsub(this) } diff --git a/packages/libp2p-daemon-server/src/index.ts b/packages/libp2p-daemon-server/src/index.ts index 354def6a..27fddb27 100644 --- a/packages/libp2p-daemon-server/src/index.ts +++ b/packages/libp2p-daemon-server/src/index.ts @@ -9,7 +9,7 @@ import { } from '@libp2p/daemon-protocol' import { StreamHandler } from '@libp2p/daemon-protocol/stream-handler' import { passThroughUpgrader } from '@libp2p/daemon-protocol/upgrader' -import { logger } from '@libp2p/logger' +import { defaultLogger, logger } from '@libp2p/logger' import { peerIdFromBytes } from '@libp2p/peer-id' import { tcp } from '@libp2p/tcp' import { multiaddr, protocols } from '@multiformats/multiaddr' @@ -58,7 +58,10 @@ export class Server implements Libp2pServer { this.multiaddr = multiaddr this.libp2p = libp2pNode - this.tcp = tcp()() + this.tcp = tcp()({ + // @ts-expect-error this field will be present post v1 + logger: defaultLogger() + }) this.listener = this.tcp.createListener({ handler: this.handleConnection.bind(this), upgrader: passThroughUpgrader