Skip to content

Instantly share code, notes, and snippets.

@JosielFaleiros
Last active November 26, 2019 21:19
Show Gist options
  • Save JosielFaleiros/29c750af6cbbcd961540098da2e30619 to your computer and use it in GitHub Desktop.
Save JosielFaleiros/29c750af6cbbcd961540098da2e30619 to your computer and use it in GitHub Desktop.
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