Skip to content

Commit

Permalink
core(fr): add logLevel to config context (#13681)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamraine committed Feb 22, 2022
1 parent f02c6b3 commit 9addbda
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 3 deletions.
6 changes: 5 additions & 1 deletion lighthouse-cli/run.js
Expand Up @@ -207,7 +207,11 @@ async function runLighthouseWithFraggleRock(url, flags, config, launchedChrome)
const browser = await puppeteer.connect({browserURL: `http://localhost:${launchedChrome.port}`});
const page = await browser.newPage();
flags.channel = 'fraggle-rock-cli';
const configContext = {configPath: flags.configPath, settingsOverrides: flags};
const configContext = {
configPath: flags.configPath,
settingsOverrides: flags,
logLevel: flags.logLevel,
};
return fraggleRock.navigation(url, {page, config, configContext});
}

Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/fraggle-rock/config/config.js
Expand Up @@ -30,7 +30,7 @@ const {
} = require('../../config/config-helpers.js');
const defaultConfigPath = path.join(__dirname, './default-config.js');

/** @typedef {Omit<LH.Config.FRContext, 'gatherMode'> & {gatherMode: LH.Gatherer.GatherMode}} ConfigContext */
/** @typedef {LH.Config.FRContext & {gatherMode: LH.Gatherer.GatherMode}} ConfigContext */

/**
* @param {LH.Config.Json|undefined} configJSON
Expand Down
2 changes: 2 additions & 0 deletions lighthouse-core/fraggle-rock/gather/navigation-runner.js
Expand Up @@ -292,6 +292,8 @@ async function _cleanup({requestedUrl, driver, config}) {
*/
async function navigation(requestor, options) {
const {page, configContext = {}} = options;
log.setLevel(configContext.logLevel || 'error');

const {config} = initializeConfig(options.config, {...configContext, gatherMode: 'navigation'});
const computedCache = new Map();
const internalOptions = {
Expand Down
3 changes: 3 additions & 0 deletions lighthouse-core/fraggle-rock/gather/snapshot-runner.js
Expand Up @@ -5,6 +5,7 @@
*/
'use strict';

const log = require('lighthouse-logger');
const Driver = require('./driver.js');
const Runner = require('../../runner.js');
const {
Expand All @@ -18,6 +19,8 @@ const {getBaseArtifacts, finalizeArtifacts} = require('./base-artifacts.js');
/** @param {{page: import('puppeteer').Page, config?: LH.Config.Json, configContext?: LH.Config.FRContext}} options */
async function snapshot(options) {
const {configContext = {}} = options;
log.setLevel(configContext.logLevel || 'error');

const {config} = initializeConfig(options.config, {...configContext, gatherMode: 'snapshot'});
const driver = new Driver(options.page);
await driver.connect();
Expand Down
3 changes: 3 additions & 0 deletions lighthouse-core/fraggle-rock/gather/timespan-runner.js
Expand Up @@ -5,6 +5,7 @@
*/
'use strict';

const log = require('lighthouse-logger');
const Driver = require('./driver.js');
const Runner = require('../../runner.js');
const {
Expand All @@ -22,6 +23,8 @@ const {getBaseArtifacts, finalizeArtifacts} = require('./base-artifacts.js');
*/
async function startTimespan(options) {
const {configContext = {}} = options;
log.setLevel(configContext.logLevel || 'error');

const {config} = initializeConfig(options.config, {...configContext, gatherMode: 'timespan'});
const driver = new Driver(options.page);
await driver.connect();
Expand Down
2 changes: 1 addition & 1 deletion types/config.d.ts
Expand Up @@ -62,10 +62,10 @@ declare module Config {
* This information is typically set by the CLI or other channel integrations.
*/
interface FRContext {
gatherMode?: Gatherer.GatherMode;
configPath?: string;
settingsOverrides?: SharedFlagsSettings & Pick<LH.Flags, 'plugins'>;
skipAboutBlank?: boolean;
logLevel?: string;
}

interface SharedPassNavigationJson {
Expand Down

0 comments on commit 9addbda

Please sign in to comment.