Skip to content

Commit

Permalink
docs(readme): fix logging in programmatic use code example (GoogleChr…
Browse files Browse the repository at this point in the history
  • Loading branch information
staceytay authored Jul 17, 2020
1 parent c159869 commit 488c7ba
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions docs/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ assumes you've installed Lighthouse as a dependency (`yarn add --dev lighthouse`
const fs = require('fs');
const lighthouse = require('lighthouse');
const chromeLauncher = require('chrome-launcher');
const log = require('lighthouse-logger');

(async () => {
log.setLevel('info');
const chrome = await chromeLauncher.launch({chromeFlags: ['--headless']});
const options = {output: 'html', onlyCategories: ['performance'], port: chrome.port};
const options = {logLevel: 'info', output: 'html', onlyCategories: ['performance'], port: chrome.port};
const runnerResult = await lighthouse('https://example.com', options);

// `.report` is the HTML report as a string
Expand Down Expand Up @@ -65,15 +63,11 @@ Note that some flag functionality is only available to the CLI. The set of share
### Turn on logging
If you want to see log output as Lighthouse runs, include the `lighthouse-logger` module
and set an appropriate logging level in your code. You'll also need to pass
If you want to see log output as Lighthouse runs, set an appropriate logging level in your code and pass
the `logLevel` flag when calling `lighthouse`.
```javascript
const log = require('lighthouse-logger');

const flags = {logLevel: 'info'};
log.setLevel(flags.logLevel);

launchChromeAndRunLighthouse('https://example.com', flags).then(...);
```
Expand Down

0 comments on commit 488c7ba

Please sign in to comment.