The `lighthouse-logger` package provides a shared logging utility class primarily used internally by the Google Lighthouse project and its associated tools. It offers basic logging capabilities with a focus on integrating within the Lighthouse ecosystem. The current stable version is 2.0.2, last published 8 months ago, and it ships with TypeScript types for improved developer experience. While the broader Lighthouse project updates frequently with Chrome DevTools releases, `lighthouse-logger` maintains a more independent and slower release cycle. Its key differentiators include its tight integration with Lighthouse's internal architecture and its minimal set of dependencies, notably `debug` and `marky`. However, discussions within the Lighthouse team suggest that maintaining `lighthouse-logger` as an external npm package is considered "awkward," and there's consideration for deprecating its external use, potentially leading to a maintenance-only status or advising direct internal referencing for Lighthouse itself.
npm install lighthouse-loggerVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to import the Logger class, set its logging level, and use various logging methods.
Review the latest Lighthouse project guidelines for logging if you intend to use it in a related project, or consider a more general-purpose logging library for independent applications.
Ensure your project uses ES Module import syntax (`import { Logger } from 'lighthouse-logger';`) and your Node.js environment is configured for ESM (e.g., `"type": "module"` in `package.json` or `.mjs` file extension).Change your import statement to use ES Modules: `import { Logger } from 'lighthouse-logger';`. If in Node.js, ensure your `package.json` has `"type": "module"` or use `.mjs` file extensions for your module.Ensure you are using named imports for `Logger`: `import { Logger } from 'lighthouse-logger';`. Avoid `import Logger from 'lighthouse-logger';` as it is not a default export.