Skip to content

Instantly share code, notes, and snippets.

@TianyiLi
Last active October 17, 2017 08:30
Show Gist options
  • Save TianyiLi/74c38c4020430eb7cb419d1e62e77625 to your computer and use it in GitHub Desktop.
Save TianyiLi/74c38c4020430eb7cb419d1e62e77625 to your computer and use it in GitHub Desktop.
javascript lines track
export function logger(...arg){
let parrent = new Error()
.stack
.split("\n")[2]
.trim()
.replace(/^at /, '')
.replace(__dirname, '')
let log = arg.forEach(e=>{ e = typeof e === 'string' ? e : JSON.stringify(e, null, 4)}).join(' ')
return log
}
export default logger
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment