js-console-consumers
v0.1.1
Published
Wraps JavaScript's console object to notify "consumers" about log/warn/... calls. Also installs handlers for window error and unhandledrejection events and calls `consumer.error()` accordingly.
Downloads
3
Readme
js-console-consumers
Wraps JavaScript's console object to notify "consumers" about log/warn/... calls. Also installs handlers for window error and unhandledrejection events and calls consumer.error()
accordingly.
Usage
import { prepareConsole } from "js-console-consumers";
prepareConsole(console);
let consumer = {log: s => window.alert("log: " + s), error: s => window.alert("error: " + s)};
console.addConsumer(c);
console.log("Hello"); // alert pops up!
// to uninstall:
console.removeConsumer(c);