-
Notifications
You must be signed in to change notification settings - Fork 2
/
log1.js
30 lines (28 loc) · 1.04 KB
/
log1.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//simple override
// usage: console.log('inside coolFunc',this,arguments);
//
// for the log history, type the following on the console
// console.log.history
// for the error history, type the following on the console
// console.error.history
//
// code based on http://paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/ (license: public domain)
(function(){
var stdLog = (this.console && console.log);
console.log = function(){
console.log.history = console.log.history || []; // store logs to an array for reference
console.log.history.push(arguments);
if(stdLog){
stdLog( Array.prototype.slice.call(arguments) );
}
};
//similar overriding as above
var stdError = (this.console && console.error);
console.log = function(){
console.log.history = console.log.history || []; // store logs to an array for reference
console.log.history.push(arguments);
if(stdLog){
stdLog( Array.prototype.slice.call(arguments) );
}
};
})();