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


TypeScript dev-utils.ToolingLog类代码示例

本文整理汇总了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;未经允许,请勿转载。