diff --git a/src/handle.ts b/src/handle.ts index a5d1606..83f4ac2 100644 --- a/src/handle.ts +++ b/src/handle.ts @@ -63,17 +63,17 @@ export async function handle (stream: Duplex, protocols: string | string[], while (true) { const protocol = await multistream.readString(reader, options) - log('read "%s"', protocol) + log.trace('read "%s"', protocol) if (protocol === PROTOCOL_ID) { - log('respond with "%s" for "%s"', PROTOCOL_ID, protocol) + log.trace('respond with "%s" for "%s"', PROTOCOL_ID, protocol) multistream.write(writer, uint8ArrayFromString(PROTOCOL_ID), options) continue } if (protocols.includes(protocol)) { multistream.write(writer, uint8ArrayFromString(protocol), options) - log('respond with "%s" for "%s"', protocol, protocol) + log.trace('respond with "%s" for "%s"', protocol, protocol) rest() return { stream: shakeStream, protocol } } @@ -82,7 +82,7 @@ export async function handle (stream: Duplex, protocols: string | string[], // \n\n\n multistream.write(writer, new Uint8ArrayList(...protocols.map(p => multistream.encode(uint8ArrayFromString(p)))), options) // multistream.writeAll(writer, protocols.map(p => uint8ArrayFromString(p))) - log('respond with "%s" for %s', protocols, protocol) + log.trace('respond with "%s" for %s', protocols, protocol) continue } diff --git a/src/select.ts b/src/select.ts index b7c0805..009d40a 100644 --- a/src/select.ts +++ b/src/select.ts @@ -68,18 +68,18 @@ export async function select (stream: Duplex, protocols: string | string[], throw new Error('At least one protocol must be specified') } - log('select: write ["%s", "%s"]', PROTOCOL_ID, protocol) + log.trace('select: write ["%s", "%s"]', PROTOCOL_ID, protocol) const p1 = uint8ArrayFromString(PROTOCOL_ID) const p2 = uint8ArrayFromString(protocol) multistream.writeAll(writer, [p1, p2], options) let response = await multistream.readString(reader, options) - log('select: read "%s"', response) + log.trace('select: read "%s"', response) // Read the protocol response if we got the protocolId in return if (response === PROTOCOL_ID) { response = await multistream.readString(reader, options) - log('select: read "%s"', response) + log.trace('select: read "%s"', response) } // We're done @@ -90,10 +90,10 @@ export async function select (stream: Duplex, protocols: string | string[], // We haven't gotten a valid ack, try the other protocols for (const protocol of protocols) { - log('select: write "%s"', protocol) + log.trace('select: write "%s"', protocol) multistream.write(writer, uint8ArrayFromString(protocol), options) const response = await multistream.readString(reader, options) - log('select: read "%s" for "%s"', response, protocol) + log.trace('select: read "%s" for "%s"', response, protocol) if (response === protocol) { rest() // End our writer so others can start writing to stream