Last active
June 12, 2017 09:12
-
-
Save lynxerzhang/7b0f9108cd14c333b82390c179f804a9 to your computer and use it in GitHub Desktop.
Revisions
-
lynxerzhang revised this gist
Jun 12, 2017 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ //@see https://www.paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/ //inspired from paulirish's console.log function !(function(win, funNameAry, titleAry, max){ max = max || 100; for(var i = 0, funName = ""; i < funNameAry.length, funName = funNameAry[i]; i ++){ -
lynxerzhang created this gist
Jun 12, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ !(function(win, funNameAry, titleAry, max){ max = max || 100; for(var i = 0, funName = ""; i < funNameAry.length, funName = funNameAry[i]; i ++){ win[funName] = (function(i, n){ return function(){ this[n].history = this[n].history || []; this[n].logMax = this[n].logMax || max; this[n].history.push(arguments); if(this[n].history.length > this[n].logMax){ this[n].history = this[n].history.slice(-this[n].logMax); } if(win.console && typeof win.console[n] === "function"){ this[n].logbind = this[n].logbind || this.console[n].bind(this.console, "[" + titleAry[i] + "]"); this[n].logbind.apply(null, Array.prototype.slice.call(arguments)); } } })(i, funName); } }(window, ["log", "warn"], ["trace", "warning"])); //usage: log("trace to console"); warn("warning for something");