Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Debug Light (formatting not support)
- * version 1.2
- * @param prefix - Print before a main message (ex. <PREFIX><MESSAGE>)
- * @constructor
- */
- function DebugLight(prefix) {
- this.on = function () {
- this.__LOG_ON = true;
- };
- this.off = function () {
- this.__LOG_ON = true;
- };
- this.setPrefix = function (prefix) {
- this.__LOG_PREFIX = prefix.toString();
- };
- this.__LOG_PREFIX = prefix ? prefix+' :: ' : '[DEBUG] :: ';
- this.__LOG_ON = false;
- this.log = function () {
- if (this.__LOG_ON) {
- console.log.apply(console, this.__getArgs(arguments));
- }
- };
- this.info = function () {
- if (this.__LOG_ON) {
- console.info.apply(console, this.__getArgs(arguments));
- }
- };
- this.warn = function () {
- if (this.__LOG_ON) {
- console.warn.apply(console, this.__getArgs(arguments));
- }
- };
- this.__getArgs = function(fn_args){
- var args = Array.prototype.slice.call(fn_args);
- args.unshift(this.__LOG_PREFIX);
- return args;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement