Last active
November 26, 2019 21:19
-
-
Save JosielFaleiros/29c750af6cbbcd961540098da2e30619 to your computer and use it in GitHub Desktop.
This file contains 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 characters
function getStackTrace () { | |
let stack | |
try { | |
throw new Error('') | |
} catch (error) { | |
stack = error.stack || '' | |
} | |
stack = stack.split('\n').map((line) => line.trim()) | |
return stack.splice(stack[0] == 'Error' ? 2 : 1) | |
} | |
console.sd = (options) => { | |
if (options.debug) console.log(options.msg + '\n' + getStackTrace()[1]) | |
else console.log(options.msg) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment