Skip to content

Commit

Permalink
Make the logger more configurable (#1471)
Browse files Browse the repository at this point in the history
  • Loading branch information
philipp-classen authored Feb 8, 2024
1 parent c1f05bc commit ab26917
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
2 changes: 1 addition & 1 deletion extension-manifest-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"@ghostery/trackers-preview": "^1.0.0",
"@ghostery/ui": "^1.0.0",
"@sentry/browser": "7.1.1",
"@whotracksme/webextension-packages": "^5.0.1",
"@whotracksme/webextension-packages": "^5.0.2",
"classnames": "^2.3.2",
"d3": "^7.8.5",
"foundation-sites": "^6.6.2",
Expand Down
2 changes: 1 addition & 1 deletion extension-manifest-v3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"@ghostery/trackers-preview": "^1.0.0",
"@ghostery/ui": "^1.0.0",
"@github/relative-time-element": "^4.3.0",
"@whotracksme/webextension-packages": "^5.0.1",
"@whotracksme/webextension-packages": "^5.0.2",
"hybrids": "^8.2.5",
"idb": "^7.1.1",
"jwt-decode": "^4.0.0",
Expand Down
21 changes: 20 additions & 1 deletion extension-manifest-v3/src/background/reporting/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
UrlReporter,
RequestReporter,
setLogLevel,
describeLoggers,
} from '@whotracksme/webextension-packages/packages/reporting';
import { getBrowserInfo } from '@ghostery/libs';

Expand All @@ -33,7 +34,21 @@ const webRequestPipeline = new WebRequestPipeline();
// Important to call it in a first tick as it assigns chrome. listeners
webRequestPipeline.init();

setLogLevel('debug');
(async () => {
try {
const key = 'ghosteryReportingLoggerConfig';
const { [key]: config } = (await chrome.storage.local.get(key)) || {};
if (config) {
for (const { level, prefix = '*' } of config) {
setLogLevel(level, { prefix });
}
} else {
setLogLevel('off');
}
} catch (e) {
console.warn('Failed to apply logger overwrites', e);
}
})();

function platformSpecificSettings() {
if (
Expand Down Expand Up @@ -261,4 +276,8 @@ globalThis.ghostery.WTM = {
config,
webRequestPipeline,
extensionStartedAt: new Date(),
logging: {
setLogLevel,
describeLoggers,
},
};
10 changes: 5 additions & 5 deletions package-lock.json

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

0 comments on commit ab26917

Please sign in to comment.