Skip to content

Instantly share code, notes, and snippets.

@owldesign
Created October 25, 2014 00:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save owldesign/dfb538acab40f26ca8db to your computer and use it in GitHub Desktop.
Save owldesign/dfb538acab40f26ca8db to your computer and use it in GitHub Desktop.
console.log wrapper
dev_mode = true;
var log;log=function(e){var t,n,r,i,s,o,u,a;if(dev_mode){try{invalidfunctionthrowanerrorplease()}catch(f){i=f;a=i.stack}s=a.split("\n");o=0;while(o<s.length){s[o]=s[o].replace(/\s+/g," ");++o}t=s[1];n=t.split("@");t=false;u=false;if(n.length===1){n=s[2].split("(");t=false;if(n.length>1){t=n[0].replace("at Object.","");u=n[1].split(":");u=u[2]}else{n[0]=n[0].replace("at ","");n=n[0].split(":");t=n[0]+n[1];u=n[2]}}else{r=n[1].split(":");u=r.pop();n[1]=r.join(":");t=n[0]===""?n[1]:n[0]}console.log(" ");console.warn("%cConsole log: "+t+" (line "+u+")",["display: block","background: #00a9c7","color: white","padding: 10px","text-align: left","font-weight: normal","font-size: 14px","line-height: 35px"].join(";"));console.log(e);console.log({"Full trace:":s});return console.log(" ")}};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment