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

Add DEBUG=1 flag #2156

Merged
merged 1 commit into from
Aug 12, 2021
Merged

Add DEBUG=1 flag #2156

merged 1 commit into from
Aug 12, 2021

Conversation

mjethani
Copy link
Contributor

This adds a DEBUG=1 flag.

make adblockplus DEBUG=1

The above should generate a file called adblockplus.debug.json in the current directory.

@mjethani mjethani requested a review from remusao as a code owner August 12, 2021 01:58
@@ -75,4 +75,11 @@ module.exports = class TSUrlFilter {
const result = this.engine.matchRequest(request);
return result.getBasicResult();
}

matchDebug({ url, frameUrl, type }) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is that matchDebug() returns something more useful than just a boolean value. In both the cases here (adblockplus and tsurlfilter) it returns the filter text.

const match = engine.match({ type: WEBREQUEST_OPTIONS[cpt], frameUrl, url });

let matchDebug = null;
if (engine.matchDebug) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the engine does not implement matchDebug() the default value is null. In the end every engine should implement something useful.

output.push({ index, url, frameUrl, cpt, match, matchDebug });
}

fs.writeFileSync(`./${ENGINE}.debug.json`, JSON.stringify(output, null, 2));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Output is pretty so it can be used with tools like diff.

@mjethani
Copy link
Contributor Author

I also have a DEBUG_DIFF=<filename> flag in mind, but I'll do it in the next step.

In the end it should be possible to do this:

make adblockplus DEBUG=1
make brave DEBUG_DIFF=adblockplus.debug.json
vi brave.diff.json

@remusao remusao added the PR: Internal 🏠 Changes only affect internals label Aug 12, 2021
@remusao remusao merged commit d941fd3 into ghostery:master Aug 12, 2021
@mjethani mjethani deleted the match-debug branch August 12, 2021 10:49
remusao pushed a commit that referenced this pull request Aug 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: Internal 🏠 Changes only affect internals
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants