2
0

console.js 667 B

12345678910111213141516171819202122232425
  1. // define a new console
  2. let consoleCounter = 0;
  3. var console=(function(oldCons){
  4. return {
  5. log: function(...text){
  6. oldCons.log(consoleCounter++,...text);
  7. // Your code
  8. },
  9. info: function (...text) {
  10. oldCons.info(consoleCounter++,...text);
  11. // Your code
  12. },
  13. warn: function (...text) {
  14. oldCons.warn(consoleCounter++,...text);
  15. // Your code
  16. },
  17. error: function (...text) {
  18. oldCons.error(consoleCounter++,...text);
  19. // Your code
  20. }
  21. };
  22. }(window.console));
  23. //Then redefine the old console
  24. window.console = console;