Created
January 14, 2023 09:39
-
-
Save HaNdTriX/d45ad7dc004f661e5bc7ffc3c6b825cc 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 createLogger(namespace) { | |
return new Proxy(console, { | |
get(target, key) { | |
return target[key].bind(target, "\x1b[33m%s\x1b[0m", namespace, "-"); | |
}, | |
}); | |
} | |
const logger = createLogger('my-namespace') | |
logger.log('foo') | |
logger.info(42) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment