Bug 1564761 [wpt PR 17620] - Document::CheckComplete should be nop when called from...
[gecko.git] / browser / extensions / screenshots / log.js
blob96be7e57edbcd417ab735a6b5cae5728a7ce4d64
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3  * You can obtain one at http://mozilla.org/MPL/2.0/. */
5 /* globals buildSettings */
6 /* eslint-disable no-console */
8 "use strict";
10 this.log = (function() {
11   const exports = {};
13   const levels = ["debug", "info", "warn", "error"];
14   if (!levels.includes(buildSettings.logLevel)) {
15     console.warn("Invalid buildSettings.logLevel:", buildSettings.logLevel);
16   }
17   const shouldLog = {};
19   {
20     let startLogging = false;
21     for (const level of levels) {
22       if (buildSettings.logLevel === level) {
23         startLogging = true;
24       }
25       if (startLogging) {
26         shouldLog[level] = true;
27       }
28     }
29   }
31   function stub() {}
32   exports.debug = exports.info = exports.warn = exports.error = stub;
34   if (shouldLog.debug) {
35     exports.debug = console.debug;
36   }
38   if (shouldLog.info) {
39     exports.info = console.info;
40   }
42   if (shouldLog.warn) {
43     exports.warn = console.warn;
44   }
46   if (shouldLog.error) {
47     exports.error = console.error;
48   }
50   return exports;
51 })();
52 null;