本文整理汇总了TypeScript中winston.warn函数的典型用法代码示例。如果您正苦于以下问题:TypeScript warn函数的具体用法?TypeScript warn怎么用?TypeScript warn使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了warn函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getRepository
public async getRepository(user: string, name: string) {
const response: request.FullResponse = await request({
auth: {
pass: this.token,
sendImmediately: true,
user: 'token'
},
headers: { 'User-Agent': 'CodeHub-Trending' },
method: 'GET',
resolveWithFullResponse: true,
url: `https://api.github.com/repos/${user}/${name}`
});
const rateLimitRemaining = parseInt(response.headers['x-ratelimit-remaining'] as string, 10);
const resetSeconds = parseInt(response.headers['x-ratelimit-reset'] as string, 10);
const nowSeconds = Math.round(new Date().getTime() / 1000);
const duration = resetSeconds - nowSeconds + 60;
// We need to drop the permission object from every repository
// because that state belongs to the user that is authenticated
// at the curren time; which is misrepresentitive of the client
// attempting to query this information.
const repoBody = _.omit(JSON.parse(response.body.toString()), 'permissions');
// Make sure we don't drain the rate limit
if (rateLimitRemaining < 400) {
winston.warn('Pausing for %s to allow rateLimit to reset', duration);
await wait(duration);
}
return repoBody;
}
示例2: pid
worker.on("exit", (code, signal) => {
var replacement, lifetime = Date.now() - startTimes[pid(worker)];
delete startTimes[pid(worker)];
if (worker.suicide) {
log.info("Worker", pid(worker), "terminated voluntarily.");
return;
}
log.info("Process", pid(worker), "terminated with signal", signal,
"code", code + "; restarting.");
if (lifetime < options.failureThreshold) {
failures++;
} else {
failures = 0;
}
if (failures > options.retryThreshold) {
log.warn(failures + " consecutive failures; pausing for",
options.retryDelay + "ms before respawning.");
}
setTimeout(() => {
replacement = spawnMore();
replacement.on("online", () =>
log.info("Process", replacement.process.pid,
"has successfully replaced", pid(worker)));
}, (failures > options.retryThreshold) ? options.retryDelay : 0);
});
示例3: Date
this.cache.dirtySock.on('message', (dirtyness:string) => {
const dirtyInfo = dirtyness.split('|');
if (dirtyInfo.length !== 2) {
winston.warn(`${new Date()}: Got weird dirty sock data? ${dirtyness}`);
return;
}
this.cache.getIdsCaches[dirtyInfo[0]] = null;
this.cache.aggregateCaches[dirtyInfo[0]] = null;
if ((dirtyInfo.length === 2) && this.cache.objectCache[dirtyInfo[0]]) {
this.cache.objectCache[dirtyInfo[0]][dirtyInfo[1]] = null;
}
});
示例4: routeNotFound
export function routeNotFound(
req: exp.Request,
res: exp.Response,
next: exp.NextFunction) {
logger.warn('route not found');
var json = {
code: 404,
name: 'API Route does not exist.',
message: 'API Route does not exist. Check the url.'
};
return res.status(json.code).json(json);
};
示例5: scrape
async function scrape(options: request.OptionsWithUrl): Promise<request.FullResponse> {
while (true) {
const result = await request({
...options,
resolveWithFullResponse: true,
simple: false
});
const { statusCode } = result;
if (statusCode === 429) {
winston.warn(`429 received (${options.url})!. Waiting 2mins.`);
await wait(60 * 2);
continue;
} else if (statusCode === 200) {
return result;
} else {
throw new Error(`Invalid status code: ${statusCode}`);
}
}
}
示例6:
.on('disconnect', (event: any) => {
winston.warn(`Disconnected [${event.code}]: ${event.reason || 'Unknown reason'}.`)
})
示例7:
const repos = await gh.getTrendingRepositories(time, langSlug).catch(err => {
winston.warn(`Error trying to retrieve repositories for ${time} ${language.name}`, err);
return [];
});