/*eslint no-var: "error"*/ /*eslint no-console: "off"*/ /*eslint-env es6*/ import Config from "core/config"; /** * Start a new debugger * @param {*} handle The string to attach to all messages from this debugger * @returns Debugger object */ export default function (handle) { let output_enabled = Config.developerdebug; if(output_enabled){ console.warn(`In development environment. Debugger output enabled for ${handle}`); } else { console.warn(`In production environment. Debugger output disabled for ${handle}`); } 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; } }; }