Last active
July 24, 2022 15:28
-
-
Save KarmaBlackshaw/33d7b4bf5ef22a2a265e5e84f14856a1 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
const chalk = require('chalk') | |
const { log } = console | |
const cwd = process.cwd() | |
function proxiedLog (...args) { | |
const line = (((new Error('log')) | |
.stack.split('\n')[2] || '…') | |
.match(/\(([^)]+)\)/) || ['not found'])[1] | |
const stack = line | |
.replace(cwd, '') | |
.replace(/^\\|^\/|\/$|\\$/g, '') | |
log.call(console, `${chalk.underline.green(stack)}:`, ...args) | |
} | |
console.info = proxiedLog | |
console.log = proxiedLog |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment