Skip to content

Instantly share code, notes, and snippets.

@HaNdTriX
Created January 14, 2023 09:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HaNdTriX/d45ad7dc004f661e5bc7ffc3c6b825cc to your computer and use it in GitHub Desktop.
Save HaNdTriX/d45ad7dc004f661e5bc7ffc3c6b825cc to your computer and use it in GitHub Desktop.
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