2016-05-23 07:10:30 +00:00
|
|
|
import "typings-global";
|
2016-05-19 17:27:09 +00:00
|
|
|
import plugins = require("./beautylog.plugins");
|
|
|
|
import {activeOra,oraActive} from "./beautylog.classes.ora";
|
|
|
|
let nativeLog = console.log;
|
2016-07-23 17:47:23 +00:00
|
|
|
let nativeError = console.error;
|
2016-05-19 17:27:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* routes the console to got through beautylog, so beautylog can take action before things are logged to console.
|
|
|
|
*/
|
2016-05-19 17:45:31 +00:00
|
|
|
let route = function(statusArg:boolean){
|
2016-05-19 17:27:09 +00:00
|
|
|
if(statusArg == true){
|
|
|
|
console.log = beautyConsole.log;
|
2016-07-23 17:47:23 +00:00
|
|
|
console.error = beautyConsole.error;
|
2016-05-19 17:27:09 +00:00
|
|
|
} else {
|
|
|
|
console.log = nativeLog;
|
|
|
|
}
|
|
|
|
|
2016-05-19 17:45:31 +00:00
|
|
|
};
|
2016-05-19 17:27:09 +00:00
|
|
|
|
|
|
|
export let beautyConsole = {
|
|
|
|
log: function(logArg:any){
|
|
|
|
if(oraActive){
|
|
|
|
activeOra.pause();
|
|
|
|
nativeLog.apply(nativeLog, arguments);
|
|
|
|
activeOra.start();
|
|
|
|
} else {
|
|
|
|
nativeLog.apply(nativeLog, arguments);
|
|
|
|
}
|
2016-07-23 17:47:23 +00:00
|
|
|
},
|
|
|
|
error: function(){
|
|
|
|
if(oraActive){
|
|
|
|
activeOra.pause();
|
|
|
|
nativeLog.apply(nativeError, arguments);
|
|
|
|
activeOra.start();
|
|
|
|
} else {
|
|
|
|
nativeLog.apply(nativeError, arguments);
|
|
|
|
}
|
2016-05-19 17:27:09 +00:00
|
|
|
}
|
2016-05-19 17:45:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
route(true);
|