Skip to content

Commit

Permalink
fix: logger type
Browse files Browse the repository at this point in the history
  • Loading branch information
DiRaiks committed May 29, 2024
1 parent de3599a commit a5436bf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/actions/ping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ export const pingAction = async (

retryCount++
const url = `https://${cid}.ipfs.${endpoint}`
logger.info(`${isTTY
logger.text(`${isTTY
? `${colors.bold(`[${retryCount}]`)}: Requesting content at ${url}`
: `[${retryCount}]`}: Requesting content at ${url}`,
)
try {
const response = await fetch(url, { signal: AbortSignal.timeout(timeout), redirect: 'follow' })
if (response.status === 504) {
if (retries > 1) {
logger.info(`🔄 Retrying in ${retryInterval / 1000} seconds...`)
logger.text(`🔄 Retrying in ${retryInterval / 1000} seconds...`)
await new Promise(resolve => setTimeout(resolve, retryInterval))
return pingAction({ cid, endpoint, options: { maxRetries: retries - 1, retryInterval } })
}
Expand All @@ -34,9 +34,9 @@ export const pingAction = async (
}
}
else {
return logger.info(`Gateway status: ${
return logger.text(`Gateway status: ${
response.status >= 200 && response.status < 400
? (isTTY ? colors.bold(colors.green(`Online ${response.status}`)) : `Online ${response.status}`)
? (isTTY ? colors.bold(colors.green(`🟢 Online ${response.status}`)) : `🟢 Online ${response.status}`)
: response.status
}`)
}
Expand Down
3 changes: 3 additions & 0 deletions src/utils/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ export const logger = {
if (isTTY) console.log('\n', method === 'GET' ? cyan(method) : green(method), url, responseStatus(status))
else console.log('\n', method, url, status)
},
text(...args: unknown[]) {
console.log(...args)
},
}

export const deployMessage = (provider: string, supports: SupportedMethods) => {
Expand Down

0 comments on commit a5436bf

Please sign in to comment.