[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(readme): fix logging in programmatic use code example #11116

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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