Paul Irish's log.history [closed]
I don't understan开发者_JAVA技巧d how to use log.history in Paul Irish's lightweight wrapper for console.log.
Just include the JS in your page. Something like this:
HTML
<html>
<head>
<!-- snip -->
<script src="path/to/console/wrapper.js"></script>
</head>
<body><!-- snip --></body>
</html>
JavaScript
// drop this in the file referenced above
window.log=function(){log.history=log.history||[];log.history.push(arguments);if(this.console){console.log(Array.prototype.slice.call(arguments))}};
This gives you a reverse-chronological history of everything that's been logged, stored in log.history
. Want to see the first thing logged?
> log.history[0]
Want to the the last thing logged?
> log.history.slice(-1)
精彩评论