How to use the lighthouse-logger.error 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 GoogleChrome / lighthouse / lighthouse-core / gather / driver.js View on Github external
_shouldToggleDomain(domain, sessionId, enable) {
    const key = domain + (sessionId || '');
    const enabledCount = this._domainEnabledCounts.get(key) || 0;
    const newCount = enabledCount + (enable ? 1 : -1);
    this._domainEnabledCounts.set(key, Math.max(0, newCount));

    // Switching to enabled or disabled, respectively.
    if ((enable && newCount === 1) || (!enable && newCount === 0)) {
      log.verbose('Driver', `${domain}.${enable ? 'enable' : 'disable'}`);
      return true;
    } else {
      if (newCount < 0) {
        log.error('Driver', `Attempted to disable domain '${domain}' when already disabled.`);
      }
      return false;
    }
  }
github GoogleChrome / lighthouse / lighthouse-core / gather / gather-runner.js View on Github external
const status = {
      msg: 'Retrieving devtoolsLog & network records',
      id: `lh:gather:getDevtoolsLog`,
    };
    log.time(status);
    const devtoolsLog = driver.endDevtoolsLog();
    const networkRecords = NetworkRecorder.recordsFromLogs(devtoolsLog);
    log.timeEnd(status);

    let pageLoadError = GatherRunner.getPageLoadError(passContext.url, networkRecords);
    // If the driver was offline, a page load error is expected, so do not save it.
    if (!driver.online) pageLoadError = undefined;

    if (pageLoadError) {
      log.error('GatherRunner', pageLoadError.message, passContext.url);
      passContext.LighthouseRunWarnings.push(pageLoadError.friendlyMessage);
    }

    // Expose devtoolsLog, networkRecords, and trace (if present) to gatherers
    /** @type {LH.Gatherer.LoadData} */
    const passData = {
      networkRecords,
      devtoolsLog,
      trace,
    };

    const apStatus = {msg: `Running afterPass methods`, id: `lh:gather:afterPass`};
    // Disable throttling so the afterPass analysis isn't throttled
    await driver.setThrottling(passContext.settings, {useThrottling: false});
    log.time(apStatus, 'verbose');
github GoogleChrome / lighthouse / lighthouse-core / computed / bundle-analysis.js View on Github external
if (line === null) {
      log.error('BundleAnalysis', `${map.url()} mapping for line out of bounds: ${lineNum + 1}`);
      return failureResult;
    }

    if (colNum > line.length) {
      // eslint-disable-next-line max-len
      log.error('BundleAnalysis', `${map.url()} mapping for column out of bounds: ${lineNum + 1}:${colNum}`);
      return failureResult;
    }

    let mappingLength = 0;
    if (lastColNum !== undefined) {
      if (lastColNum > line.length) {
        // eslint-disable-next-line max-len
        log.error('BundleAnalysis', `${map.url()} mapping for last column out of bounds: ${lineNum + 1}:${lastColNum}`);
        return failureResult;
      }
      mappingLength = lastColNum - colNum;
    } else {
      // TODO Buffer.byteLength?
      // Add +1 to account for the newline.
      mappingLength = line.length - colNum + 1;
    }
    files[source] = (files[source] || 0) + mappingLength;
    unmappedBytes -= mappingLength;
  }

  return {
    files,
    unmappedBytes,
    totalBytes,
github GoogleChrome / chrome-launcher / src / chrome-launcher.ts View on Github external
.catch(err => {
              if (retries > launcher.maxConnectionRetries) {
                log.error('ChromeLauncher', err.message);
                const stderr =
                    this.fs.readFileSync(`${this.userDataDir}/chrome-err.log`, {encoding: 'utf-8'});
                log.error(
                    'ChromeLauncher', `Logging contents of ${this.userDataDir}/chrome-err.log`);
                log.error('ChromeLauncher', stderr);
                return reject(err);
              }
              delay(launcher.connectionPollInterval).then(poll);
            });
      };
github GoogleChrome / lighthouse / lighthouse-cli / performance-experiment / server.js View on Github external
}).catch(err => {
        log.error('PerformanceXServer', err.code, err);
        response.writeHead(500);
        response.end(http.STATUS_CODES[500]);
      });
    });
github avanslaars / code-profiles / egghead / exts / wallabyjs.quokka-vscode-1.0.142 / dist / wallaby / node_modules / chrome-launcher / chrome-launcher.js View on Github external
.catch(function (err) {
                    if (retries > launcher.maxConnectionRetries) {
                        log.error('ChromeLauncher', err.message);
                        var stderr = _this.fs.readFileSync(_this.userDataDir + "/chrome-err.log", { encoding: 'utf-8' });
                        log.error('ChromeLauncher', "Logging contents of " + _this.userDataDir + "/chrome-err.log");
                        log.error('ChromeLauncher', stderr);
                        return reject(err);
                    }
                    utils_1.delay(launcher.connectionPollInterval).then(poll);
                });
            };
github GoogleChrome / lighthouse / lighthouse-core / lib / traces / pwmetrics-events.js View on Github external
generateFakeEvents() {
    const metrics = this.gatherMetrics();
    if (metrics.length === 0) {
      log.error('metrics-events', 'Metrics collection had errors, not synthetizing trace events');
      return [];
    }

    const navigationStartEvt = this.getNavigationStartEvt(metrics);
    if (!navigationStartEvt) {
      log.error('pwmetrics-events', 'Reference navigationStart not found');
      return [];
    }

    /** @type {Array} */
    const fakeEvents = [];
    metrics.forEach(metric => {
      if (metric.id === 'navstart') {
        return;
      }
      if (!metric.ts) {
github GoogleChrome / lighthouse / lighthouse-core / gather / connections / extension.js View on Github external
return this._queryCurrentTab().then(tab => {
      if (!tab.url) {
        log.error('ExtensionConnection', 'getCurrentTabURL returned empty string', tab);
        throw new Error('getCurrentTabURL returned empty string');
      }
      return tab.url;
    });
  }
github GoogleChrome / lighthouse / lighthouse-core / lib / traces / pwmetrics-events.js View on Github external
generateFakeEvents() {
    const metrics = this.gatherMetrics();
    if (metrics.length === 0) {
      log.error('metrics-events', 'Metrics collection had errors, not synthetizing trace events');
      return [];
    }

    const navigationStartEvt = this.getNavigationStartEvt(metrics);
    if (!navigationStartEvt) {
      log.error('pwmetrics-events', 'Reference navigationStart not found');
      return [];
    }

    /** @type {Array} */
    const fakeEvents = [];
    metrics.forEach(metric => {
      if (metric.id === 'navstart') {
        return;
      }
      if (!metric.ts) {
        log.error('pwmetrics-events', `(${metric.name}) missing timestamp. Skipping…`);
        return;
      }
      log.verbose('pwmetrics-events', `Sythesizing trace events for ${metric.name}`);
      fakeEvents.push(...this.synthesizeEventPair(metric, navigationStartEvt));
    });
github GoogleChrome / chrome-launcher / src / chrome-launcher.ts View on Github external
.catch(err => {
              if (retries > launcher.maxConnectionRetries) {
                log.error('ChromeLauncher', err.message);
                const stderr =
                    this.fs.readFileSync(`${this.userDataDir}/chrome-err.log`, {encoding: 'utf-8'});
                log.error(
                    'ChromeLauncher', `Logging contents of ${this.userDataDir}/chrome-err.log`);
                log.error('ChromeLauncher', stderr);
                return reject(err);
              }
              delay(launcher.connectionPollInterval).then(poll);
            });
      };