Skip to content

Commit 9addbda

Browse files
authoredFeb 22, 2022
core(fr): add logLevel to config context (#13681)
1 parent f02c6b3 commit 9addbda

File tree

6 files changed

+15
-3
lines changed

6 files changed

+15
-3
lines changed
 

‎lighthouse-cli/run.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,11 @@ async function runLighthouseWithFraggleRock(url, flags, config, launchedChrome)
207207
const browser = await puppeteer.connect({browserURL: `http://localhost:${launchedChrome.port}`});
208208
const page = await browser.newPage();
209209
flags.channel = 'fraggle-rock-cli';
210-
const configContext = {configPath: flags.configPath, settingsOverrides: flags};
210+
const configContext = {
211+
configPath: flags.configPath,
212+
settingsOverrides: flags,
213+
logLevel: flags.logLevel,
214+
};
211215
return fraggleRock.navigation(url, {page, config, configContext});
212216
}
213217

‎lighthouse-core/fraggle-rock/config/config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const {
3030
} = require('../../config/config-helpers.js');
3131
const defaultConfigPath = path.join(__dirname, './default-config.js');
3232

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

3535
/**
3636
* @param {LH.Config.Json|undefined} configJSON

‎lighthouse-core/fraggle-rock/gather/navigation-runner.js

+2
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,8 @@ async function _cleanup({requestedUrl, driver, config}) {
292292
*/
293293
async function navigation(requestor, options) {
294294
const {page, configContext = {}} = options;
295+
log.setLevel(configContext.logLevel || 'error');
296+
295297
const {config} = initializeConfig(options.config, {...configContext, gatherMode: 'navigation'});
296298
const computedCache = new Map();
297299
const internalOptions = {

‎lighthouse-core/fraggle-rock/gather/snapshot-runner.js

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
'use strict';
77

8+
const log = require('lighthouse-logger');
89
const Driver = require('./driver.js');
910
const Runner = require('../../runner.js');
1011
const {
@@ -18,6 +19,8 @@ const {getBaseArtifacts, finalizeArtifacts} = require('./base-artifacts.js');
1819
/** @param {{page: import('puppeteer').Page, config?: LH.Config.Json, configContext?: LH.Config.FRContext}} options */
1920
async function snapshot(options) {
2021
const {configContext = {}} = options;
22+
log.setLevel(configContext.logLevel || 'error');
23+
2124
const {config} = initializeConfig(options.config, {...configContext, gatherMode: 'snapshot'});
2225
const driver = new Driver(options.page);
2326
await driver.connect();

‎lighthouse-core/fraggle-rock/gather/timespan-runner.js

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
'use strict';
77

8+
const log = require('lighthouse-logger');
89
const Driver = require('./driver.js');
910
const Runner = require('../../runner.js');
1011
const {
@@ -22,6 +23,8 @@ const {getBaseArtifacts, finalizeArtifacts} = require('./base-artifacts.js');
2223
*/
2324
async function startTimespan(options) {
2425
const {configContext = {}} = options;
26+
log.setLevel(configContext.logLevel || 'error');
27+
2528
const {config} = initializeConfig(options.config, {...configContext, gatherMode: 'timespan'});
2629
const driver = new Driver(options.page);
2730
await driver.connect();

‎types/config.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ declare module Config {
6262
* This information is typically set by the CLI or other channel integrations.
6363
*/
6464
interface FRContext {
65-
gatherMode?: Gatherer.GatherMode;
6665
configPath?: string;
6766
settingsOverrides?: SharedFlagsSettings & Pick<LH.Flags, 'plugins'>;
6867
skipAboutBlank?: boolean;
68+
logLevel?: string;
6969
}
7070

7171
interface SharedPassNavigationJson {

0 commit comments

Comments
 (0)
Please sign in to comment.