Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | 5x 5x | import { IEndpoint } from '../endpoints/endpoints'
import { AxiosRequestConfig } from 'axios'
import { getUrlFromConfig } from './base.utils'
export class Logger {
// Private methods
private static parseName (endpoint: IEndpoint, uri?: string) {
let text = `${endpoint.prefix}/${endpoint.path}`
if (uri) {
text += ` (${uri})`
}
return text
}
// Public methods
static start (endpoint: IEndpoint, uri?: string) {
const name = Logger.parseName(endpoint, uri)
console.time(name)
}
static end (endpoint: IEndpoint, uri?: string) {
const name = Logger.parseName(endpoint, uri)
console.timeEnd(name)
}
static uri (config: AxiosRequestConfig, endpoint: IEndpoint) {
const url = getUrlFromConfig(config)
console.log(`Calling method url: ${url} (${endpoint.path})`)
}
static rateLimit (endpoint: IEndpoint, ms: number) {
const name = Logger.parseName(endpoint)
console.log(`Waiting ${(ms / 1000).toFixed(2)} seconds by rate limit (${name})`)
}
}
|