当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript winston.warn函数代码示例

本文整理汇总了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;
  }
开发者ID:thedillonb,项目名称:GitHub-Trending,代码行数:32,代码来源:github.ts

示例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);
    });
开发者ID:FutureAdLabs,项目名称:hellojoe,代码行数:30,代码来源:hellojoe.ts

示例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;
   }
 });
开发者ID:kingsquare,项目名称:communibase-connector-js,代码行数:12,代码来源:index.ts

示例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);
};
开发者ID:jokecamp,项目名称:liams-picks,代码行数:15,代码来源:index.ts

示例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}`);
    }
  }
}
开发者ID:thedillonb,项目名称:GitHub-Trending,代码行数:21,代码来源:github.ts

示例6:

 .on('disconnect', (event: any) => {
     winston.warn(`Disconnected [${event.code}]: ${event.reason || 'Unknown reason'}.`)
 })
开发者ID:tinnvec,项目名称:stonebot,代码行数:3,代码来源:app.ts

示例7:

 const repos = await gh.getTrendingRepositories(time, langSlug).catch(err => {
   winston.warn(`Error trying to retrieve repositories for ${time} ${language.name}`, err);
   return [];
 });
开发者ID:thedillonb,项目名称:GitHub-Trending,代码行数:4,代码来源:main.ts


注:本文中的winston.warn函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。