Skip to content

Instantly share code, notes, and snippets.

@arxae
Created June 13, 2021 22:42
Show Gist options
  • Save arxae/4f62354dd23b558aac7a5037ff0aee26 to your computer and use it in GitHub Desktop.
Save arxae/4f62354dd23b558aac7a5037ff0aee26 to your computer and use it in GitHub Desktop.
console.log stuff
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