@@ -11,11 +11,45 @@ module openflow {
1111 export type mapFunc = ( ) => void ;
1212 export type reduceFunc = ( key : string , values : any [ ] ) => any ;
1313 export type finalizeFunc = ( key : string , value : any ) => any ;
14-
14+ const getCircularReplacer = ( ) => {
15+ const seen = new WeakSet ( ) ;
16+ return ( key , value ) => {
17+ if ( typeof value === "object" && value !== null ) {
18+ if ( seen . has ( value ) ) {
19+ return ;
20+ }
21+ seen . add ( value ) ;
22+ }
23+ return value ;
24+ } ;
25+ } ;
1526 export class api {
1627 static $inject = [ "$rootScope" , "$location" , "WebSocketClient" ] ;
1728 public messageQueue : IHashTable < messagequeue > = { } ;
1829 constructor ( public $rootScope : ng . IRootScopeService , public $location , public WebSocketClient : WebSocketClient ) {
30+ var formerlog = console . log . bind ( window . console ) ;
31+ var formerwarn = console . warn . bind ( window . console ) ;
32+ var formerdebug = console . debug . bind ( window . console ) ;
33+ console . log = ( msg ) => {
34+ formerlog . apply ( console , { arguments : arguments } ) ;
35+ var log = { message : msg , _type : "message" } ;
36+ this . Insert ( "jslog" , log ) ;
37+ }
38+ console . warn = ( msg ) => {
39+ formerwarn . apply ( console , { arguments : arguments } ) ;
40+ var log = { message : msg , _type : "warning" } ;
41+ this . Insert ( "jslog" , log ) ;
42+ }
43+ console . debug = ( msg ) => {
44+ formerdebug . apply ( console , { arguments : arguments } ) ;
45+ var log = { message : msg , _type : "debug" } ;
46+ this . Insert ( "jslog" , log ) ;
47+ }
48+ window . onerror = ( message , url , linenumber ) => {
49+ var log = { message : message , url : url , linenumber : linenumber , _type : "error" } ;
50+ this . Insert ( "jslog" , log ) ;
51+ }
52+
1953
2054 var cleanup = $rootScope . $on ( 'queuemessage' , ( event , data : QueueMessage ) => {
2155 if ( event && data ) { }
0 commit comments