Skip to content

Instantly share code, notes, and snippets.

@aaronmccall
Created September 2, 2019 00:28
Show Gist options
  • Save aaronmccall/a0e7d52c1fc94764c024db15576a3878 to your computer and use it in GitHub Desktop.
Save aaronmccall/a0e7d52c1fc94764c024db15576a3878 to your computer and use it in GitHub Desktop.
Add seconds.milliseconds at the end of every console call
const now = () => new Date().toISOString().replace(/^.*:([\d.]+)Z$/, '$1')
if (
process.env.NODE_ENV === 'development'
|| (localStorage.debug === 'true' && !console.__ts__)
) {
['log', 'debug', 'info', 'warn', 'error'].forEach(method => {
const original = console[method]
console[method] = (...args) => original.call(console, ...args, `| ${now()}`)
})
console.__ts__ = true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment