• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript loge.logger类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中loge.logger的典型用法代码示例。如果您正苦于以下问题:TypeScript logger类的具体用法?TypeScript logger怎么用?TypeScript logger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了logger类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: callback

 }, (error: Error, result) => {
   if (error) {
     logger.error('failed to insert batch: %s', error.message);
     return callback(error);
   }
   logger.debug('inserting batch took %d ms', result.took);
   if (result.errors) {
     logger.warning('batch insert encountered non-fatal errors: %j', result.errors);
   }
   callback();
 });
开发者ID:chbrown,项目名称:npm-search-server,代码行数:11,代码来源:database.ts


示例2: normalizePackage

  fs.readFile(REGISTRY_CACHE_FILEPATH, {encoding: 'utf8'}, (err, data) => {
    // all we need from the cache is the latest `_updated` value
    if (err || data === '') {
      data = '{"_updated":0}';
    }
    var registry = JSON.parse(data);
    var _updated: number = registry._updated;

    // updating the locally-cached registry file happens the same way regardless
    // of the updates_only flag
    var url = `https://registry.npmjs.org/-/all/since?stale=update_after&startkey=${_updated}`;
    logger.debug('fetching url: "%s"', url);
    request.get({url: url, json: true}, (error, response, body) => {
      if (error) return callback(error);

      logger.debug('fetched %d updates', Object.keys(body).length - 1);

      // update and save the cached registry, but don't wait for it
      _.assign(registry, body);
      fs.writeFile(REGISTRY_CACHE_FILEPATH, JSON.stringify(registry), {encoding: 'utf8'}, (error) => {
        if (error) {
          return logger.error('failed to save registry: %s', error.message);
        }
        logger.debug('saved updated registry file');
      });

      var names = updates_only ? Object.keys(body) : Object.keys(registry);
      var packages = names.filter(name => name !== '_updated').map(name => normalizePackage(registry[name]));
      callback(null, packages);
    });
  });
开发者ID:chbrown,项目名称:npm-search-server,代码行数:31,代码来源:registry.ts


示例3: mergeAverageDownloadsPerDay

    mergeAverageDownloadsPerDay(packages, (error, packages) => {
      if (error) return callback(error);

      logger.debug('updating with %d packages (%s)', packages.length, updates_only ? 'updates only' : 'all packages');
      var batches = _.chunk(packages, 500);
      async.eachSeries(batches, insertPackages, callback);
    });
开发者ID:chbrown,项目名称:npm-search-server,代码行数:7,代码来源:database.ts


示例4:

const server = http.createServer((req, res) => {
  logger.debug('%s %s', req.method, req.url)
  // enable CORS
  res.setHeader('Access-Control-Allow-Origin', '*')
  res.setHeader('Access-Control-Allow-Methods', '*')
  controller.route(req, res)
})
开发者ID:chbrown,项目名称:npm-history,代码行数:7,代码来源:index.ts


示例5: insertPackages

function insertPackages(packages: registry.Package[], callback: (error?: Error) => void) {
  logger.debug('inserting batch of %d packages, from %s to %s', packages.length,
    packages[0].name, packages[packages.length - 1].name);

  var body = [];
  packages.forEach(pkg => {
    body.push({index: {_id: pkg.name}}, pkg);
  });

  client.bulk({
    index: 'npm',
    type: 'packages',
    body: body
  }, (error: Error, result) => {
    if (error) {
      logger.error('failed to insert batch: %s', error.message);
      return callback(error);
    }
    logger.debug('inserting batch took %d ms', result.took);
    if (result.errors) {
      logger.warning('batch insert encountered non-fatal errors: %j', result.errors);
    }
    callback();
  });
}
开发者ID:chbrown,项目名称:npm-search-server,代码行数:25,代码来源:database.ts


示例6: callback

 .execute((error: Error, rows: {name: string, average: number}[]) => {
   if (error) return callback(error)
   logger.info('averaged downloads for %d packages', rows.length)
   const packages: {[index: string]: number} = {}
   rows.forEach(row => packages[row.name] = row.average)
   callback(null, packages)
 })
开发者ID:chbrown,项目名称:npm-history,代码行数:7,代码来源:database.ts


示例7: determineNeededEndpoints

    .execute((selectError: Error, local_statistics: Statistic[]) => {
      if (selectError) return callback(selectError)

      // 2. determine what we want to get next
      const [start, end] = determineNeededEndpoints(local_statistics, min_range_days, max_range_days)

      // 3. determineNeededEndpoints may return [null, null] if there are no
      // remaining ranges that we need to fetch
      if (start === null && end === null) {
        logger.debug('not fetching any data for "%s"', name)
        return callback(null, local_statistics)
      }

      // 4. get the next unseen statistics
      getRangeStatistics(name, start, end, (statsError, statistics) => {
        if (statsError) return callback(statsError)

        // 5. save the values we just fetched
        const [sql, args] = buildMultirowInsert(package_row.id, statistics)
        db.executeSQL(sql, args, (sqlError: Error) => {
          if (sqlError) return callback(sqlError)

          // 6. merge local and new statistics for the response
          const total_statistics = statistics.concat(local_statistics).sort((a, b) => a.day.getTime() - b.day.getTime())
          callback(null, total_statistics)
        })
      })
    })
开发者ID:chbrown,项目名称:npm-history,代码行数:28,代码来源:database.ts


示例8: Parser

 readableStream.pipe(new Parser({lowerCaseTags: argv.lower === true})).on('finish', function() {
   logger.debug('document=%j', this.document);
   const xmlSerializer = new XMLSerializer('  ', argv.limit);
   const formattedHTML = xmlSerializer.serializeToString(this.document);
   process.stdout.write(formattedHTML);
   process.stdout.write('\n');
 });
开发者ID:chbrown,项目名称:domlike,代码行数:7,代码来源:htmlfmt.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript Logger.Logger类代码示例发布时间:2022-05-25
下一篇:
TypeScript log4js.Logger类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap