當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。