Recipe 16.3
Creating Named Loggers
Demo
Open the console to see output.
Code
JavaScript
function createLogger(name, color) {
return console.log.bind(console, `%c${name}`, `color: ${color};`);
}
const rendererLogger = createLogger('renderer', 'blue');
const dataLogger = createLogger('data', 'green');
rendererLogger('Rendering component');
dataLogger('Fetching data');
HTML
Open the console to see output.