Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { store } from './index';
- export const hijackConsole = () => {
- const OG_LOG = console.log;
- console.log = function(...args) {
- // map over arguments and convert
- // objects in to readable strings
- const messages = [...args].map(msg => {
- return typeof msg !== 'string'
- ? JSON.stringify(msg)
- : msg;
- }).join(' ');
- store.dispatch({
- type: CONSOLE_LOG,
- messages
- });
- // retain original functionality
- OG_LOG.apply(console, [...args]);
- };
- };
Add Comment
Please, Sign In to add comment