Skip to content

Instantly share code, notes, and snippets.

@Zielak
Last active June 30, 2017 19:23
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 Zielak/c45544dff63903b929a43cc141dc917e to your computer and use it in GitHub Desktop.
Save Zielak/c45544dff63903b929a43cc141dc917e to your computer and use it in GitHub Desktop.
Wraps console log, warn, info and error. Will add module's name before printing log. Userful when you have bunch of modules logging different stuff
const MODULE_NAME = 'ModuleX'
const log = (...args) => console.log.apply(console, [`[${MODULE_NAME}] > `, ...args])
const info = (...args) => console.info.apply(console, [`[${MODULE_NAME}] > `, ...args])
const warn = (...args) => console.warn.apply(console, [`[${MODULE_NAME}] > `, ...args])
const error = (...args) => console.error.apply(console, [`[${MODULE_NAME}] > `, ...args])
log('testing', ['apple', 'orange', 'car'], 1337)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment