Skip to content

Commit df6432c

Browse files
Make the logger more configurable
1 parent c1f05bc commit df6432c

File tree

1 file changed

+20
-1
lines changed
  • extension-manifest-v3/src/background/reporting

1 file changed

+20
-1
lines changed

extension-manifest-v3/src/background/reporting/index.js

+20-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
UrlReporter,
1919
RequestReporter,
2020
setLogLevel,
21+
describeLoggers,
2122
} from '@whotracksme/webextension-packages/packages/reporting';
2223
import { getBrowserInfo } from '@ghostery/libs';
2324

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

36-
setLogLevel('debug');
37+
(async () => {
38+
try {
39+
const key = 'ghosteryReportingLoggerConfig';
40+
const { [key]: config } = (await chrome.storage.local.get(key)) || {};
41+
if (config) {
42+
for (const { level, prefix = '*' } of config) {
43+
setLogLevel(level, prefix);
44+
}
45+
} else {
46+
setLogLevel('off');
47+
}
48+
} catch (e) {
49+
console.warn('Failed to apply logger overwrites', e);
50+
}
51+
})();
3752

3853
function platformSpecificSettings() {
3954
if (
@@ -261,4 +276,8 @@ globalThis.ghostery.WTM = {
261276
config,
262277
webRequestPipeline,
263278
extensionStartedAt: new Date(),
279+
logging: {
280+
setLogLevel,
281+
describeLoggers,
282+
},
264283
};

0 commit comments

Comments
 (0)