Skip to content

chore: filter debug logs by prefix #129

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

Merged
merged 3 commits into from
Jun 27, 2025
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/puppeteer-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cloudflare/puppeteer",
"version": "1.0.2",
"version": "1.0.3",
"description": "A high-level API to control headless Chrome over the DevTools Protocol",
"keywords": [
"puppeteer",
Expand Down
12 changes: 12 additions & 0 deletions packages/puppeteer-core/src/common/Debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ export const debug = (prefix: string): ((...args: unknown[]) => void) => {
if (captureLogs) {
capturedLogs.push(prefix + logArgs);
}
const debugLevel = process.env['DEBUG'] || '';
const everythingShouldBeLogged = debugLevel === '*';

const prefixMatchesDebugLevel =
everythingShouldBeLogged ||
(debugLevel.endsWith('*')
? prefix.startsWith(debugLevel)
: prefix === debugLevel);

if (!prefixMatchesDebugLevel) {
return;
}
(await importDebug())(prefix)(logArgs);
};
}
Expand Down
2 changes: 1 addition & 1 deletion packages/puppeteer-core/src/generated/version.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
* @internal
*/
export const packageVersion = '1.0.2';
export const packageVersion = '1.0.3';
2 changes: 1 addition & 1 deletion test-workers/src/tests/__snapshots__/coverage.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`browser does basic manipulations > gets the title of google developers website 1`] = `"Bytes used: 17.31673853390827%"`;
exports[`browser does basic manipulations > gets the title of google developers website 1`] = `"Bytes used: 78.76923076923077%"`;
Binary file modified test-workers/src/tests/__snapshots__/image.test.ts.snap
Binary file not shown.
Loading