Skip to content

Instantly share code, notes, and snippets.

@brophdawg11
Created September 21, 2018 15:01
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 brophdawg11/b58b78f2ec94e4de72b6b0ec11edbc06 to your computer and use it in GitHub Desktop.
Save brophdawg11/b58b78f2ec94e4de72b6b0ec11edbc06 to your computer and use it in GitHub Desktop.
Dead Simple LogLevel-driven Logging
const logLevel = process.env.LOG_LEVEL;
const noop = () => {};
export default {
debug:
logLevel === 'debug' ?
console.debug.bind(console) :
noop,
info:
(logLevel === 'debug' ||
logLevel === 'info') ?
console.info.bind(console) :
noop,
log:
(logLevel === 'debug' ||
logLevel === 'info' ||
logLevel === 'log') ?
console.log.bind(console) :
noop,
warn:
(logLevel === 'debug' ||
logLevel === 'info' ||
logLevel === 'log' ||
logLevel === 'warn') ?
console.warn.bind(console) :
noop,
error:
(logLevel === 'debug' ||
logLevel === 'info' ||
logLevel === 'log' ||
logLevel === 'warn' ||
logLevel === 'error') ?
console.error.bind(console) :
noop,
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment