Guest User

Untitled

a guest
Nov 19th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. import { store } from './index';
  2.  
  3. export const hijackConsole = () => {
  4. const OG_LOG = console.log;
  5. console.log = function(...args) {
  6. // map over arguments and convert
  7. // objects in to readable strings
  8. const messages = [...args].map(msg => {
  9. return typeof msg !== 'string'
  10. ? JSON.stringify(msg)
  11. : msg;
  12. }).join(' ');
  13. store.dispatch({
  14. type: CONSOLE_LOG,
  15. messages
  16. });
  17. // retain original functionality
  18. OG_LOG.apply(console, [...args]);
  19. };
  20. };
Add Comment
Please, Sign In to add comment