proxyConsole.js 426 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/* @flow */
type ConsoleProxyCallback = (message: string) => void;
const permanentRegister = function proxyConsole(
  type: string,
  callback: ConsoleProxyCallback
) {
  const orig = console[type];
  console[type] = function __stack_frame_overlay_proxy_console__() {
    const message = [].slice.call(arguments).join(' ');
    callback(message);
    return orig.apply(this, arguments);
  };
};

export { permanentRegister };