Files
tubestation/browser/extensions/screenshots/webextension/log.js
Mark Banner d2d9626164 Bug 1346825 - Import Screenshots version 6.3.0 into mozilla-central. rs=Mossop.
This is imported from https://github.com/mozilla-services/screenshots/.
It has been reviewed as patches landed, but also reviewed by Mossop and kmag.
This also includes the patch from bug 1356394

MozReview-Commit-ID: FXIVw7WjxlN
2017-04-13 09:49:17 +01:00

48 lines
958 B
JavaScript

/* globals buildSettings */
"use strict";
this.log = (function () {
let exports = {};
const levels = ["debug", "info", "warn", "error"];
if (! levels.includes(buildSettings.logLevel)) {
console.warn("Invalid buildSettings.logLevel:", buildSettings.logLevel);
}
let shouldLog = {};
{
let startLogging = false;
for (let level of levels) {
if (buildSettings.logLevel === level) {
startLogging = true;
}
if (startLogging) {
shouldLog[level] = true;
}
}
}
function stub() {}
exports.debug = exports.info = exports.warn = exports.error = stub;
if (shouldLog.debug) {
exports.debug = console.debug.bind(console);
}
if (shouldLog.info) {
exports.info = console.info.bind(console);
}
if (shouldLog.warn) {
exports.warn = console.warn.bind(console);
}
if (shouldLog.error) {
exports.error = console.error.bind(console);
}
return exports;
})();
null;