Skip to content

Commit

Permalink
chore: log string casing
Browse files Browse the repository at this point in the history
  • Loading branch information
SgtPooki committed Mar 7, 2024
1 parent deb2f2b commit f357a3d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
4 changes: 2 additions & 2 deletions packages/verified-fetch/src/utils/byte-range-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class ByteRangeContext {
this.log = logger.forComponent('helia:verified-fetch:byte-range-context')
this._rangeRequestHeader = getHeader(this.headers, 'Range')
if (this._rangeRequestHeader != null) {
this.log.trace('Range request detected')
this.log.trace('range request detected')
this._isRangeRequest = true
try {
const { start, end } = getByteRangeFromHeader(this._rangeRequestHeader)
Expand All @@ -71,7 +71,7 @@ export class ByteRangeContext {

this.setOffsetDetails()
} else {
this.log.trace('No range request detected')
this.log.trace('no range request detected')
this._isRangeRequest = false
this.requestRangeStart = null
this.requestRangeEnd = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export async function getStreamFromAsyncIterable (iterator: AsyncIterable<Uint8A
const { value: firstChunk, done } = await reader.next()

if (done === true) {
log.error('No content found for path', path)
log.error('no content found for path', path)
throw new Error('No content found')
}

Expand Down
10 changes: 5 additions & 5 deletions packages/verified-fetch/src/utils/parse-url-string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export async function parseUrlString ({ urlString, ipns, logger }: ParseUrlStrin
log.trace('resolved %s to %c from cache', cidOrPeerIdOrDnsLink, cid)
} else {
// protocol is ipns
log.trace('Attempting to resolve PeerId for %s', cidOrPeerIdOrDnsLink)
log.trace('attempting to resolve PeerId for %s', cidOrPeerIdOrDnsLink)
let peerId = null

try {
Expand All @@ -90,16 +90,16 @@ export async function parseUrlString ({ urlString, ipns, logger }: ParseUrlStrin
ipnsCache.set(cidOrPeerIdOrDnsLink, resolveResult, 60 * 1000 * 2)
} catch (err) {
if (peerId == null) {
log.error('Could not parse PeerId string "%s"', cidOrPeerIdOrDnsLink, err)
log.error('could not parse PeerId string "%s"', cidOrPeerIdOrDnsLink, err)
errors.push(new TypeError(`Could not parse PeerId in ipns url "${cidOrPeerIdOrDnsLink}", ${(err as Error).message}`))
} else {
log.error('Could not resolve PeerId %c', peerId, err)
log.error('could not resolve PeerId %c', peerId, err)
errors.push(new TypeError(`Could not resolve PeerId "${cidOrPeerIdOrDnsLink}", ${(err as Error).message}`))
}
}

if (cid == null) {
log.trace('Attempting to resolve DNSLink for %s', cidOrPeerIdOrDnsLink)
log.trace('attempting to resolve DNSLink for %s', cidOrPeerIdOrDnsLink)

try {
resolveResult = await ipns.resolveDns(cidOrPeerIdOrDnsLink, { onProgress: options?.onProgress })
Expand All @@ -108,7 +108,7 @@ export async function parseUrlString ({ urlString, ipns, logger }: ParseUrlStrin
log.trace('resolved %s to %c', cidOrPeerIdOrDnsLink, cid)
ipnsCache.set(cidOrPeerIdOrDnsLink, resolveResult, 60 * 1000 * 2)
} catch (err: any) {
log.error('Could not resolve DnsLink for "%s"', cidOrPeerIdOrDnsLink, err)
log.error('could not resolve DnsLink for "%s"', cidOrPeerIdOrDnsLink, err)
errors.push(err)
}
}
Expand Down
9 changes: 4 additions & 5 deletions packages/verified-fetch/src/verified-fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ export class VerifiedFetch {
ipfsRoots = pathDetails.ipfsRoots
terminalElement = pathDetails.terminalElement
} catch (err) {
this.log.error('Error walking path %s', path, err)
this.log.error('error walking path %s', path, err)

return internalServerErrorResponse('Error walking path')
}
Expand Down Expand Up @@ -369,9 +369,8 @@ export class VerifiedFetch {

return response
} catch (err: any) {
this.log.error('Error streaming %c/%s', cid, path, err)
this.log.error('error streaming %c/%s', cid, path, err)
if (byteRangeContext.isRangeRequest && err.code === 'ERR_INVALID_PARAMS') {
// this.log.error('Invalid range request for %c/%s', cid, path)
return badRangeResponse(resource)
}
return internalServerErrorResponse('Unable to stream content')
Expand Down Expand Up @@ -422,7 +421,7 @@ export class VerifiedFetch {
contentType = parsed
}
} catch (err) {
this.log.error('Error parsing content type', err)
this.log.error('error parsing content type', err)
}
}
this.log.trace('setting content type to "%s"', contentType)
Expand Down Expand Up @@ -503,7 +502,7 @@ export class VerifiedFetch {
query.filename = query.filename ?? `${cid.toString()}.tar`
response = await this.handleTar(handlerArgs)
} else {
this.log.trace('Finding handler for cid code "%s" and output type "%s"', cid.code, accept)
this.log.trace('finding handler for cid code "%s" and output type "%s"', cid.code, accept)
// derive the handler from the CID type
const codecHandler = this.codecHandlers[cid.code]

Expand Down

0 comments on commit f357a3d

Please sign in to comment.