Skip to content

Instantly share code, notes, and snippets.

@wences-dc-uba-ar
Created June 5, 2019 13:47
Show Gist options
  • Save wences-dc-uba-ar/0ccc8120e635a40f621562a57a64ffc9 to your computer and use it in GitHub Desktop.
Save wences-dc-uba-ar/0ccc8120e635a40f621562a57a64ffc9 to your computer and use it in GitHub Desktop.
Javascript snippets
/**
* indented prettyPrint caller function
*/
function fcallerName() {
var err = new Error();
var stack = err.stack.split("\n");
var lft = " ".substr(0, stack.length-3);
return [
"%c" + lft + "FUNCTION " + fcallerName.caller.caller.name + "()",
"background: #222; color: #bada55;",
stack.reverse().slice(0,-3)
];
}
function log() {
var args = fcallerName(), len = arguments.length;
while ( len-- ) args[ len + 3 ] = arguments[ len ];
// if(args[0].includes("someFunctionName")) {
console.log.apply(console, args); // eslint-disable-line no-console
// }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment