Skip to content

Commit

Permalink
Logging tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
muodov committed Nov 23, 2023
1 parent 7c84dec commit 5a57d06
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/cmps/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default class AutoConsentCMPBase implements AutoCMP {
}

const snippetSrc = getFunctionBody(snippet);
enableLogs && console.log('async eval:', snippetId, snippetSrc);
// enableLogs && console.log('async eval:', snippetId, snippetSrc);
return requestEval(snippetSrc).catch((e) => {
enableLogs && console.error('error evaluating rule', snippetId, e);
return false;
Expand Down
1 change: 1 addition & 0 deletions lib/config.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
// TODO: make this configurable through DevTools (and possibly toggleable per rule step type)
export const enableLogs = false; // change this to enable debug logs
2 changes: 1 addition & 1 deletion lib/rule-executors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function elementVisible(selector: ElementSelector, check: VisibilityCheck
export function waitForElement(selector: ElementSelector, timeout = 10000): Promise<boolean> {
const interval = 200;
const times = Math.ceil((timeout) / interval);
// enableLogs && console.log("[waitFor]", ruleStep.waitFor);
enableLogs && console.log("[waitForElement]", selector);
return waitFor(
() => elementSelector(selector).length > 0,
times,
Expand Down
4 changes: 2 additions & 2 deletions lib/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export default class AutoConsent {
declarativeRules.autoconsent.forEach((ruleset) => {
this.addDeclarativeCMP(ruleset);
});
enableLogs && console.log("added rules", this.rules);
// enableLogs && console.log("added rules", this.rules);
}

addDeclarativeCMP(ruleset: AutoConsentCMPRule) {
Expand Down Expand Up @@ -397,7 +397,7 @@ export default class AutoConsent {
}

async receiveMessageCallback(message: BackgroundMessage) {
if (enableLogs && ['evalResp', 'report'].includes(message.type) /* evals are noisy */) {
if (enableLogs && !['evalResp', 'report'].includes(message.type) /* evals are noisy */) {
console.log('received from background', message, window.location.href);
}
switch (message.type) {
Expand Down

0 comments on commit 5a57d06

Please sign in to comment.