MDN self-hosted library · e01.org

console: context() static method

Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.

js
const logger = console.context("myLogger");
logger.log("Hello");
logger.info("World");
js
const a = console.context("A");
const b = console.context("B");

console.count("hits"); // hits: 1
a.count("hits"); // hits: 1
a.count("hits"); // hits: 2
b.count("hits"); // hits: 1
console.count("hits"); // hits: 2