How to use the lighthouse-logger.setLevel function in lighthouse-logger

To help you get started, we’ve selected a few lighthouse-logger examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ebidel / lighthouse-hue / index.js View on Github external
.version(() => require('./package.json').version)
  .alias('v', 'version')
  .showHelpOnFail(false, 'Specify --help for available options')
  .boolean(['reset', 'view', 'headless'])
  .default('output', 'html')
  .default('output-path', './public/results.html')
  .default('log-level', 'info')
  .argv;
flags.chromePath = process.env.CHROME_PATH || null;

const url = yargs.argv._[0];

const runner = new LighthouseRunner(url, flags);//, PERF_CONFIG);
const lights = new HueLights(BRIDGE_IP, USERNAME);

Log.setLevel(flags.logLevel);

/**
 * Creates new "Lighthouse" user on the Hue bridge if needed.
 */
function createHueUserIfNeeded() {
  const setHostNamePromise = BRIDGE_IP ? Promise.resolve(BRIDGE_IP) :
                                         lights.setHostnameOfBridge();
  return setHostNamePromise
    .then(hostname => lights.config())
    .then(config => {
      // Username is registered with the Hue.
      if ('linkbutton' in config) {
        console.log(`${Log.purple}Hue:${Log.reset} Re-using known user`);
        return lights.username;
      }
github angular / angular / aio / scripts / audit-web-app.js View on Github external
const lhFlags = {...LIGHTHOUSE_FLAGS, onlyCategories: Object.keys(minScores).sort()};
  const lhConfig = {
    extends: 'lighthouse:default',
    // Since the Angular ServiceWorker waits for the app to stabilize before registering,
    // wait a few seconds after load to allow Lighthouse to reliably detect it.
    passes: [{passName: 'defaultPass', pauseAfterLoadMs: WAIT_FOR_SW_DELAY}],
  };

  console.log(`Running web-app audits for '${url}'...`);
  console.log(`  Audit categories: ${lhFlags.onlyCategories.join(', ')}`);

  // If testing on HTTP, skip HTTPS-specific tests.
  // (Note: Browsers special-case localhost and run ServiceWorker even on HTTP.)
  if (isOnHttp) skipHttpsAudits(lhConfig);

  logger.setLevel(lhFlags.logLevel);

  try {
    console.log('');
    const startTime = Date.now();
    const results = await launchChromeAndRunLighthouse(url, lhFlags, lhConfig);
    const success = await processResults(results, minScores, logFile);
    console.log(`\n(Completed in ${((Date.now() - startTime) / 1000).toFixed(1)}s.)\n`);

    if (!success) {
      throw new Error('One or more scores are too low.');
    }
  } catch (err) {
    onError(err);
  }
}
github GoogleChrome / lighthouse / lighthouse-cli / bin.js View on Github external
if (cliFlags.preset === 'mixed-content') {
    // The mixed-content audits require headless Chrome (https://crbug.com/764505).
    cliFlags.chromeFlags = `${cliFlags.chromeFlags} --headless`;
  }

  configJson = require(`../lighthouse-core/config/${cliFlags.preset}-config.js`);
}

// set logging preferences
cliFlags.logLevel = 'info';
if (cliFlags.verbose) {
  cliFlags.logLevel = 'verbose';
} else if (cliFlags.quiet) {
  cliFlags.logLevel = 'silent';
}
log.setLevel(cliFlags.logLevel);

if (
  cliFlags.output.length === 1 &&
  cliFlags.output[0] === printer.OutputMode.json &&
  !cliFlags.outputPath
) {
  cliFlags.outputPath = 'stdout';
}

if (cliFlags.extraHeaders) {
  // TODO: LH.Flags.extraHeaders is actually a string at this point, but needs to be
  // copied over to LH.Settings.extraHeaders, which is LH.Crdp.Network.Headers. Force
  // the conversion here, but long term either the CLI flag or the setting should have
  // a different name.
  // @ts-ignore
  let extraHeadersStr = /** @type {string} */ (cliFlags.extraHeaders);
github addyosmani / webpack-lighthouse-plugin / src / lighthouse-bin.js View on Github external
function lighthouseRun(addresses, config, lighthouseFlags, chrome) {
    // Enable a programatic consumer to pass custom flags otherwise default to CLI.
    lighthouseFlags = lighthouseFlags || flags;
    lighthouseFlags.logLevel = lighthouseFlags.logLevel || 'info';
    lighthouseFlags.output = lighthouseFlags.output || 'html';
    log.setLevel(lighthouseFlags.logLevel);
    lighthouseFlags.port = chrome.port;
    // Process URLs once at a time
    const address = addresses.shift();
    if (!address) {
        return chrome;
    }
    return lighthouse(address, lighthouseFlags)
    .then((results) => {
        const artifacts = results.artifacts;
        delete results.artifacts;
        return saveResults(results, artifacts, lighthouseFlags);
    })
    .then((results) => {
        return lighthouseRun(addresses, config, lighthouseFlags, chrome);
    }).then(result => result);
github treosh / lighthouse-ci-action / node_modules / lighthouse / lighthouse-core / index.js View on Github external
async function lighthouse(url, flags = {}, configJSON, connection) {
  // set logging preferences, assume quiet
  flags.logLevel = flags.logLevel || 'error';
  log.setLevel(flags.logLevel);

  const config = generateConfig(configJSON, flags);

  connection = connection || new ChromeProtocol(flags.port, flags.hostname);

  // kick off a lighthouse run
  return Runner.run(connection, {url, config});
}
github GoogleChrome / lighthouse / lighthouse-core / index.js View on Github external
async function lighthouse(url, flags = {}, configJSON, connection) {
  // set logging preferences, assume quiet
  flags.logLevel = flags.logLevel || 'error';
  log.setLevel(flags.logLevel);

  const config = generateConfig(configJSON, flags);

  connection = connection || new ChromeProtocol(flags.port, flags.hostname);

  // kick off a lighthouse run
  return Runner.run(connection, {url, config});
}
github ngrx / platform / projects / ngrx.io / scripts / test-pwa-score.js View on Github external
function _main(args) {
  const {url, minScore, logFile} = parseInput(args);
  const isOnHttp = /^http:/.test(url);

  console.log(`Running PWA audit for '${url}'...`);

  if (isOnHttp) {
    skipHttpsAudits(config);
  }

  logger.setLevel(LIGHTHOUSE_FLAGS.logLevel);

  launchChromeAndRunLighthouse(url, LIGHTHOUSE_FLAGS, config).
    then(results => processResults(results, logFile)).
    then(score => evaluateScore(minScore, score)).
    catch(onError);
}
github IBM / page-lab / pageaudit / pagelab.js View on Github external
const program = require('commander');
const lighthouse = require('lighthouse');
const chromeLauncher = require('chrome-launcher');

const validUrl = require('valid-url');
const fetch = require('node-fetch');
const RedisSMQ = require('rsmq');
const redis = require('redis');
const jsonify = require('redis-jsonify');
const express = require('express');
const shell = require('shelljs');

const log = require('lighthouse-logger');
const LOG_LEVEL = process.env['PL_LH_LOG_LEVEL'] || 'error';
log.setLevel(LOG_LEVEL);

const VERSION = '0.0.2';
const PL_APP_NAME = 'PageLab';
const PL_EXPRESS_PORT = 1717;

const MAX_RUNS_BEFORE_RESTART = process.env['PAGE_LAB_MAX_RUNS_BEFORE_RESTART'] || 1000;
const WORKERS_CLEARED_TS = 'workersClearedTS';
var SERVER_START_TS = Date.now();

const MSG_REPORT_URL = 'Worker url is:';
const MSG_WORKER_DISCONNECT = 'Worker disconnecting...';
const ACTION_CHROME_PID = 100;
const ACTION_COLLECTION_COMPLETE = 101;
const ACTION_REPORT_URL = 1000;

const SUCCESS_RUNS = 'successfulRuns';