moodle_local_treestudyplan/amd/src/debugger.js

51 lines
1.6 KiB
JavaScript
Raw Normal View History

/*eslint no-var: "error"*/
/*eslint no-console: "off"*/
/*eslint-env es6*/
// Put this file in path/to/plugin/amd/src
// You can call it anything you like
define([], function () {
return (function (handle) {
let output_enabled = false;
return {
write: function debugger_write() {
if (output_enabled) {
let args = Array.prototype.slice.call(arguments);
args.unshift(handle + ": ");
console.info.apply(console, args);
}
},
info: function debugger_info() {
if (output_enabled) {
let args = Array.prototype.slice.call(arguments);
args.unshift(handle + ": ");
console.info.apply(console, args);
}
},
warn: function debugger_warn() {
if (output_enabled) {
let args = Array.prototype.slice.call(arguments);
args.unshift(handle + ": ");
console.warn.apply(console, args);
}
},
error: function debugger_error() {
if (output_enabled) {
let args = Array.prototype.slice.call(arguments);
args.unshift(handle + ": ");
console.error.apply(console, args);
}
},
enable: function debugger_enable() {
output_enabled = true;
},
disable: function debugger_disable() {
output_enabled = false;
}
};
});
});