Skip to content

Instantly share code, notes, and snippets.

@DavesCodeMusings
Created May 30, 2022 19:03
Show Gist options
  • Select an option

  • Save DavesCodeMusings/0e0e89a04b64453d27350e14edfb1470 to your computer and use it in GitHub Desktop.

Select an option

Save DavesCodeMusings/0e0e89a04b64453d27350e14edfb1470 to your computer and use it in GitHub Desktop.
Suppress showing of debug messages by replacing console.debug() with a custom function that checks a 'debug' flag before logging.
#!/usr/bin/env node
let _console_debug = console.debug
console.debug = function(message) {
if (debug) {
_console_debug.apply(console, arguments)
}
}
let debug = true
console.debug("This should be shown.")
debug = false
console.debug("This should be suppressed.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment