Last active
January 14, 2021 03:27
-
-
Save keyle/49146f053c000e082c3cd4992fc0abba to your computer and use it in GitHub Desktop.
console.log by topic on/off
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 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