Created
June 13, 2021 22:42
-
-
Save arxae/4f62354dd23b558aac7a5037ff0aee26 to your computer and use it in GitHub Desktop.
console.log stuff
This file contains 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
export function getConsole(name: string, color: string) { | |
const newConsole : Console = Object.create(console); | |
newConsole.log = console.log.bind(console, `%c[${name}]`, `color: ${color}`); | |
newConsole.warn = console.warn.bind(console, `[${name}]`); | |
newConsole.error = console.error.bind(console, `[${name}]`); | |
newConsole.time = (label?: string) => console.time(`[${name}] ${label}`); | |
newConsole.timeEnd = (label?: string) => console.timeEnd(`[${name}] ${label}`); | |
return newConsole; | |
} | |
// Usage | |
var console = getConsole('RequestManager', '#f0f'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment