Skip to content

Instantly share code, notes, and snippets.

@keyle
Last active January 14, 2021 03:27
Show Gist options
  • Select an option

  • Save keyle/49146f053c000e082c3cd4992fc0abba to your computer and use it in GitHub Desktop.

Select an option

Save keyle/49146f053c000e082c3cd4992fc0abba to your computer and use it in GitHub Desktop.
console.log by topic on/off
/**
* logt() - extremely simple `console.log` by topic
* instead `logt('topic', something)`;
* to turn on, `localStorage.topic=1` in chrome console
* to turn off, `delete localStorage.topic`
* @param {string} topic
* @param args
*/
let logt = (topic, ...args) => {
if (localStorage[topic]) {
console.log(...args);
}
};
/**
* warnt() - extremely simple `console.warn` by topic
* @param {string} topic
* @param args
*/
let warnt = (topic, ...args) => {
if (localStorage[topic]) {
console.warn(...args);
}
};
/**
* errt() - extremely simple `console.error` by topic
* @param {string} topic
* @param args
*/
let errt = (topic, ...args) => {
if (localStorage[topic]) {
console.error(...args);
}
};
/**
* log() - general purpose one
* @param args
*/
let log = (...args) => {
if (localStorage.log) {
console.log(...args);
}
};
export {log, logt, warnt, errt};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment