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

TypeScript dev-utils.ToolingLog类代码示例

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

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



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

示例1: onFailure

export async function retryForSuccess<T>(log: ToolingLog, options: Options<T>) {
  const { timeout, methodName, block, accept = returnTrue } = options;
  const { onFailure = defaultOnFailure(methodName) } = options;

  const start = Date.now();
  const retryDelay = 502;
  let lastError;

  while (true) {
    if (lastError && Date.now() - start > timeout) {
      await onFailure(lastError);
      throw new Error('expected onFailure() option to throw an error');
    }

    const attempt = await runAttempt(block);

    if ('result' in attempt && accept(attempt.result)) {
      return attempt.result;
    }

    if ('error' in attempt) {
      if (lastError && lastError.message === attempt.error.message) {
        log.debug(`--- ${methodName} failed again with the same message...`);
      } else {
        log.debug(`--- ${methodName} error: ${attempt.error.message}`);
      }

      lastError = attempt.error;
    }

    await delay(retryDelay);
  }
}
开发者ID:njd5475,项目名称:kibana,代码行数:33,代码来源:retry_for_success.ts


示例2: lintFiles

export async function lintFiles(log: ToolingLog, files: File[]) {
  for (const [project, filesInProject] of groupFilesByProject(files)) {
    const exitCode = await run(
      {
        exclude: [],
        files: filesInProject.map(f => f.getAbsolutePath()),
        fix: false,
        format: 'stylish',
        project: project.tsConfigPath,
      },
      {
        log(m: string) {
          log.write(m);
        },
        error(m: string) {
          log.error(m);
        },
      }
    );

    if (exitCode > 0) {
      throw createFailError(`[tslint] failure`, 1);
    } else {
      log.success(
        '[tslint/%s] %d files linted successfully',
        project.name,
        filesInProject.length
      );
    }
  }
}
开发者ID:JinlongHe,项目名称:kibana,代码行数:31,代码来源:lint_files.ts


示例3: attemptToCreateCommand

async function attemptToCreateCommand(log: ToolingLog, browserType: 'chrome' | 'firefox') {
  const attemptId = ++attemptCounter;
  log.debug('[webdriver] Creating session');

  const buildDriverInstance = async () => {
    switch (browserType) {
      case 'chrome':
        const chromeOptions = new chrome.Options();
        const loggingPref = new logging.Preferences();
        loggingPref.setLevel(logging.Type.BROWSER, logging.Level.ALL);
        chromeOptions.setLoggingPrefs(loggingPref);
        if (process.env.TEST_BROWSER_HEADLESS) {
          // Use --disable-gpu to avoid an error from a missing Mesa library, as per
          // See: https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md
          chromeOptions.addArguments('headless', 'disable-gpu');
        }
        return new Builder()
          .forBrowser(browserType)
          .setChromeOptions(chromeOptions)
          .setChromeService(new chrome.ServiceBuilder(chromeDriver.path).enableVerboseLogging())
          .build();
      case 'firefox':
        const firefoxOptions = new firefox.Options();
        if (process.env.TEST_BROWSER_HEADLESS) {
          // See: https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Headless_mode
          firefoxOptions.addArguments('-headless');
        }
        return new Builder()
          .forBrowser(browserType)
          .setFirefoxOptions(firefoxOptions)
          .setFirefoxService(new firefox.ServiceBuilder(geckoDriver.path).enableVerboseLogging())
          .build();
      default:
        throw new Error(`${browserType} is not supported yet`);
    }
  };

  const session = await buildDriverInstance();

  if (throttleOption === 'true' && browserType === 'chrome') {
    // Only chrome supports this option.
    log.debug('NETWORK THROTTLED: 768k down, 256k up, 100ms latency.');

    (session as any).setNetworkConditions({
      offline: false,
      latency: 100, // Additional latency (ms).
      download_throughput: 768 * 1024, // These speeds are in bites per second, not kilobytes.
      upload_throughput: 256 * 1024,
    });
  }

  if (attemptId !== attemptCounter) {
    return;
  } // abort

  return { driver: session, By, Key, until, LegacyActionSequence };
}
开发者ID:spalger,项目名称:kibana,代码行数:57,代码来源:webdriver.ts


示例4: comparePngs

export async function comparePngs(
  sessionPath: string,
  baselinePath: string,
  diffPath: string,
  sessionDirectory: string,
  log: ToolingLog
) {
  log.debug(`comparePngs: ${sessionPath} vs ${baselinePath}`);
  const session = (await Jimp.read(sessionPath)).clone();
  const baseline = (await Jimp.read(baselinePath)).clone();

  if (
    session.bitmap.width !== baseline.bitmap.width ||
    session.bitmap.height !== baseline.bitmap.height
  ) {
    // eslint-disable-next-line no-console
    console.log(
      'expected height ' + baseline.bitmap.height + ' and width ' + baseline.bitmap.width
    );
    // eslint-disable-next-line no-console
    console.log('actual height ' + session.bitmap.height + ' and width ' + session.bitmap.width);

    const width = Math.min(session.bitmap.width, baseline.bitmap.width);
    const height = Math.min(session.bitmap.height, baseline.bitmap.height);
    session.resize(width, height); // , Jimp.HORIZONTAL_ALIGN_LEFT | Jimp.VERTICAL_ALIGN_TOP);
    baseline.resize(width, height); // , Jimp.HORIZONTAL_ALIGN_LEFT | Jimp.VERTICAL_ALIGN_TOP);
  }

  session.quality(60);
  baseline.quality(60);

  log.debug(`calculating diff pixels...`);
  // Note that this threshold value only affects color comparison from pixel to pixel. It won't have
  // any affect when comparing neighboring pixels - so slight shifts, font variations, or "blurry-ness"
  // will still show up as diffs, but upping this will not help that.  Instead we keep the threshold low, and expect
  // some the diffCount to be lower than our own threshold value.
  const THRESHOLD = 0.1;
  const { image, percent } = Jimp.diff(session, baseline, THRESHOLD);
  log.debug(`percent different: ${percent}`);
  if (percent > 0) {
    image.write(diffPath);

    // For debugging purposes it'll help to see the resized images and how they compare.
    session.write(join(sessionDirectory, `${parse(sessionPath).name}-session-resized.png`));
    baseline.write(join(sessionDirectory, `${parse(baselinePath).name}-baseline-resized.png`));
  }
  return percent;
}
开发者ID:elastic,项目名称:kibana,代码行数:48,代码来源:compare_pngs.ts


示例5: getSettingsFromFile

async function getSettingsFromFile(log: ToolingLog, path: string, settingOverrides: any) {
  const configModule = require(path); // eslint-disable-line @typescript-eslint/no-var-requires
  const configProvider = configModule.__esModule ? configModule.default : configModule;

  if (!cache.has(configProvider)) {
    log.debug('Loading config file from %j', path);
    cache.set(
      configProvider,
      configProvider({
        log,
        async readConfigFile(p: string, o: any) {
          return new Config({
            settings: await getSettingsFromFile(log, p, o),
            primary: false,
            path: p,
          });
        },
      })
    );
  }

  const settingsWithDefaults = defaultsDeep({}, settingOverrides, await cache.get(configProvider)!);

  const logDeprecation = (error: string | Error) => log.error(error);
  return transformDeprecations(settingsWithDefaults, logDeprecation);
}
开发者ID:elastic,项目名称:kibana,代码行数:26,代码来源:read_config_file.ts


示例6: startTestServers

export async function startTestServers({
  adjustTimeout,
  settings = {},
}: {
  adjustTimeout: (timeout: number) => void;
  settings: Record<string, any>;
}) {
  if (!adjustTimeout) {
    throw new Error('adjustTimeout is required in order to avoid flaky tests');
  }

  const log = new ToolingLog({
    level: 'debug',
    writeTo: process.stdout,
  });

  log.indent(6);
  log.info('starting elasticsearch');
  log.indent(4);

  const es = createEsTestCluster({ log });

  log.indent(-4);

  adjustTimeout(es.getStartTimeout());

  await es.start();

  const root = createRootWithCorePlugins(settings);
  await root.start();

  const kbnServer = getKbnServer(root);
  await kbnServer.server.plugins.elasticsearch.waitUntilReady();

  return {
    kbnServer,
    root,
    es,

    async stop() {
      await root.shutdown();
      await es.cleanup();
    },
  };
}
开发者ID:gingerwizard,项目名称:kibana,代码行数:45,代码来源:kbn_server.ts


示例7: function

      return function(this: any, ...args: any[]) {
        log.verbose(`${name}.${prop}(${printArgs(args)})`);
        log.indent(2);

        let result;
        try {
          result = {
            returned: value.apply(this, args),
          };
        } catch (error) {
          result = {
            returned: undefined,
            thrown: error,
          };
        }

        if (result.hasOwnProperty('thrown')) {
          log.indent(-2);
          throw result.thrown;
        }

        const { returned } = result;
        if (returned && typeof returned.then === 'function') {
          return returned.finally(() => {
            log.indent(-2);
          });
        }

        log.indent(-2);
        return returned;
      };
开发者ID:elastic,项目名称:kibana,代码行数:31,代码来源:verbose_instance.ts


示例8: if

 messageCallback: (message: ExtractorMessage) => {
   if (message.messageId === 'console-api-report-not-copied') {
     // ConsoleMessageId.ApiReportNotCopied
     log.warning(`You have changed the signature of the ${folder} Core API`);
     log.warning(
       'To accept these changes run `node scripts/check_core_api_changes.js --accept` and then:\n' +
         "\t 1. Commit the updated documentation and API review file '" +
         config.reportFilePath +
         "' \n" +
         "\t 2. Describe the change in your PR including whether it's a major, minor or patch"
     );
     message.handled = true;
   } else if (message.messageId === 'console-api-report-copied') {
     // ConsoleMessageId.ApiReportCopied
     log.warning(`You have changed the signature of the ${folder} Core API`);
     log.warning(
       "Please commit the updated API documentation and the review file in '" +
         config.reportFilePath
     );
     message.handled = true;
   } else if (message.messageId === 'console-api-report-unchanged') {
     // ConsoleMessageId.ApiReportUnchanged
     log.info(`Core ${folder} API: no changes detected ✔`);
     message.handled = true;
   }
 },
开发者ID:horacimacias,项目名称:kibana,代码行数:26,代码来源:run_check_core_api_changes.ts


示例9: setInterval

    this.loggingInterval = setInterval(() => {
      if (this.complete === undefined) {
        return;
      }

      if (this.total === undefined) {
        log.info('progress: %d', this.getComplete());
        return;
      }

      log.info('progress: %d/%d (%d%)', this.getComplete(), this.getTotal(), this.getPercent());
    }, 10 * SECOND);
开发者ID:elastic,项目名称:kibana,代码行数:12,代码来源:progress.ts


示例10:

  list.run().catch((error: any) => {
    process.exitCode = 1;

    if (!error.errors) {
      log.error('Unhandled exception!');
      log.error(error);
      process.exit();
    }

    for (const e of error.errors) {
      if (e instanceof ProjectFailure) {
        log.write('');
        log.error(`${e.project.name} failed\n${e.error.stdout}`);
      } else {
        log.error(e);
      }
    }
  });
开发者ID:austec-automation,项目名称:kibana,代码行数:18,代码来源:exec_in_projects.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript elastic-idx.idx函数代码示例发布时间:2022-05-28
下一篇:
TypeScript config-schema.schema类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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