@@ -220,188 +220,197 @@ var logDumper = (function($, module) {
220220 $table ,
221221 $toggle ,
222222 $toggleNodes ;
223- if ( method === "alert" ) {
224- $node = $ ( '<div class="alert"></div>' ) ;
225- var message = args . message
226- ? atob ( args . message )
227- : atob ( args [ 0 ] ) ;
228- var className = args . message
229- ? atob ( args . message ) // pre 2.1.0
230- : meta . class ;
231- var dismissible = args . message
232- ? args . dismissible
233- : meta . dismissible ;
234- $node . addClass ( "alert-" + className )
235- . html ( message ) ;
236- if ( dismissible ) {
237- $node . prepend ( '<button type="button" class="close" data-dismiss="alert" aria-label="Close">'
238- + '<span aria-hidden="true">×</span>'
239- + '</button>' ) ;
240- $node . addClass ( "alert-dismissible" ) ;
241- }
242- $container . find ( ".debug-header" ) . before ( $node ) ;
243- } else if ( method == "endOutput" ) {
244- $container . removeClass ( "working" ) ;
245- $container . find ( ".panel-heading .fa-spinner" ) . remove ( ) ;
246- $container . find ( ".panel-body > .fa-spinner" ) . remove ( ) ;
247- $ . each ( args , function ( i , arg ) {
248- if ( typeof arg != "string" ) {
249- return ;
223+ try {
224+ if ( method === "alert" ) {
225+ $node = $ ( '<div class="alert"></div>' ) ;
226+ var message = args . message
227+ ? atob ( args . message )
228+ : atob ( args [ 0 ] ) ;
229+ var className = args . message
230+ ? atob ( args . message ) // pre 2.1.0
231+ : meta . class ;
232+ var dismissible = args . message
233+ ? args . dismissible
234+ : meta . dismissible ;
235+ $node . addClass ( "alert-" + className )
236+ . html ( message ) ;
237+ if ( dismissible ) {
238+ $node . prepend ( '<button type="button" class="close" data-dismiss="alert" aria-label="Close">'
239+ + '<span aria-hidden="true">×</span>'
240+ + '</button>' ) ;
241+ $node . addClass ( "alert-dismissible" ) ;
250242 }
251- args [ i ] = atob ( arg ) ;
252- } ) ;
253- if ( args . responseCode && args . responseCode != "200" ) {
254- $container . find ( ".panel-title" ) . append ( ' <span class="label label-default" title="Response Code">' + args . responseCode + '</span>' ) ;
255- if ( args . responseCode . toString ( ) . match ( '/^5/' ) ) {
243+ $container . find ( ".debug-header" ) . before ( $node ) ;
244+ } else if ( method == "endOutput" ) {
245+ $container . removeClass ( "working" ) ;
246+ $container . find ( ".panel-heading .fa-spinner" ) . remove ( ) ;
247+ $container . find ( ".panel-body > .fa-spinner" ) . remove ( ) ;
248+ $ . each ( args , function ( i , arg ) {
249+ if ( typeof arg != "string" ) {
250+ return ;
251+ }
252+ args [ i ] = atob ( arg ) ;
253+ } ) ;
254+ if ( args . responseCode && args . responseCode != "200" ) {
255+ $container . find ( ".panel-title" ) . append ( ' <span class="label label-default" title="Response Code">' + args . responseCode + '</span>' ) ;
256+ if ( args . responseCode . toString ( ) . match ( '/^5/' ) ) {
257+ $container . addClass ( "panel-danger" ) ;
258+ }
259+ }
260+ } else if ( method == 'errorNotConsoled' ) {
261+ $node = $container . find ( '.alert.error-summary' ) ;
262+ if ( ! $node . length ) {
263+ $node = $ ( '<div class="alert alert-danger error-summary">' +
264+ '<h3><i class="fa fa-lg fa-times-circle"></i> Error(s)</h3>' +
265+ '<ul class="list-unstyled indent">' +
266+ '</ul>' +
267+ '</div>' ) ;
268+ $container . find ( ".panel-body" ) . prepend ( $node ) ;
269+ }
270+ $node = $node . find ( 'ul' ) ;
271+ $node . append ( $ ( "<li></li>" ) . text ( atob ( args [ 0 ] ) ) ) ;
272+ if ( meta . class == "danger" ) {
273+ // console.log('panel-danger');
256274 $container . addClass ( "panel-danger" ) ;
275+ $container . removeClass ( 'panel-warning' ) ; // could keep it.. but lets remove ambiguity
276+ } else if ( ! $container . hasClass ( "panel-danger" ) ) {
277+ // console.log('panel warning');
278+ $container . addClass ( "panel-warning" ) ;
257279 }
258- }
259- } else if ( method == 'errorNotConsoled' ) {
260- $node = $container . find ( '.alert.error-summary' ) ;
261- if ( ! $node . length ) {
262- $node = $ ( '<div class="alert alert-danger error-summary">' +
263- '<h3><i class="fa fa-lg fa-times-circle"></i> Error(s)</h3>' +
264- '<ul class="list-unstyled indent">' +
265- '</ul>' +
266- '</div>' ) ;
267- $container . find ( ".panel-body" ) . prepend ( $node ) ;
268- }
269- $node = $node . find ( 'ul' ) ;
270- $node . append ( $ ( "<li></li>" ) . text ( atob ( args [ 0 ] ) ) ) ;
271- if ( meta . class == "danger" ) {
272- // console.log('panel-danger');
273- $container . addClass ( "panel-danger" ) ;
274- $container . removeClass ( 'panel-warning' ) ; // could keep it.. but lets remove ambiguity
275- } else if ( ! $container . hasClass ( "panel-danger" ) ) {
276- // console.log('panel warning');
277- $container . addClass ( "panel-warning" ) ;
278- }
279- $container . removeClass ( 'panel-default' ) ;
280- } else if ( [ "group" , "groupCollapsed" ] . indexOf ( method ) > - 1 ) {
281- $groupHeader = groupHeader ( method , args , meta ) ;
282- $node = $ ( "<div>" ) . addClass ( "m_group" ) ;
283- $currentNode . append ( $groupHeader ) ;
284- $currentNode . append ( $node ) ;
285- $container . data ( "currentNode" , $node ) ;
286- } else if ( method == "groupSummary" ) {
287- // see if priority already exists
288- var priority = args [ 0 ] ;
289- $container . find ( ".debug-header .m_groupSummary" ) . each ( function ( ) {
290- var priorityCur = $ ( this ) . data ( "priority" ) ;
291- if ( priorityCur == priority ) {
292- $node = $ ( this ) ;
293- return false ; // break
294- } else if ( priorityCur < priority ) {
280+ $container . removeClass ( 'panel-default' ) ;
281+ } else if ( [ "group" , "groupCollapsed" ] . indexOf ( method ) > - 1 ) {
282+ $groupHeader = groupHeader ( method , args , meta ) ;
283+ $node = $ ( "<div>" ) . addClass ( "m_group" ) ;
284+ $currentNode . append ( $groupHeader ) ;
285+ $currentNode . append ( $node ) ;
286+ $container . data ( "currentNode" , $node ) ;
287+ } else if ( method == "groupSummary" ) {
288+ // see if priority already exists
289+ var priority = args [ 0 ] ;
290+ $container . find ( ".debug-header .m_groupSummary" ) . each ( function ( ) {
291+ var priorityCur = $ ( this ) . data ( "priority" ) ;
292+ if ( priorityCur == priority ) {
293+ $node = $ ( this ) ;
294+ return false ; // break
295+ } else if ( priorityCur < priority ) {
296+ $node = $ ( "<div>" ) . addClass ( "m_groupSummary" ) . data ( "priority" , priority ) ;
297+ $ ( this ) . before ( $node ) ;
298+ return false ; // break
299+ }
300+ } ) ;
301+ if ( ! $node ) {
295302 $node = $ ( "<div>" ) . addClass ( "m_groupSummary" ) . data ( "priority" , priority ) ;
296- $ ( this ) . before ( $node ) ;
297- return false ; // break
303+ $container
304+ . find ( ".debug-header" )
305+ . append ( $node ) ;
298306 }
299- } ) ;
300- if ( ! $node ) {
301- $node = $ ( "<div>" ) . addClass ( "m_groupSummary" ) . data ( "priority" , priority ) ;
302- $container
303- . find ( ".debug-header" )
304- . append ( $node ) ;
305- }
306- $container . data ( "currentNodeSummary" , $node ) ;
307- } else if ( method == "groupEnd" ) {
308- if ( $currentNode . is ( ".m_groupSummary" ) ) {
309- $container . removeData ( "currentNodeSummary" ) ;
310- return ;
311- }
312- $toggle = $currentNode . prev ( ) ;
313- // console.info('groupEnd', $toggle.text());
314- if ( ! $currentNode . is ( ".debug-content" ) ) {
315- $container . data ( "currentNode" , $currentNode . parent ( ) ) ;
316- }
317- if ( $toggle . hasClass ( "empty" ) && $toggle . hasClass ( "hide-if-empty" ) ) {
318- $toggle . remove ( ) ;
319- $currentNode . remove ( ) ;
320- }
321- if ( $toggle . is ( ":visible" ) ) {
322- $toggle . debugEnhance ( ) ;
323- }
324- } else if ( method == "groupUncollapse" ) {
325- // console.log('expand');
326- $toggleNodes = $currentNode . parentsUntil ( ".debug-header, .debug-content" ) . add ( $currentNode ) . prev ( ) ;
327- $toggleNodes . removeClass ( "collapsed" ) . addClass ( "expanded" ) ;
328- } else if ( method === "meta" ) {
329- $ . each ( args , function ( i , arg ) {
330- if ( typeof arg != "string" ) {
307+ $container . data ( "currentNodeSummary" , $node ) ;
308+ } else if ( method == "groupEnd" ) {
309+ if ( $currentNode . is ( ".m_groupSummary" ) ) {
310+ $container . removeData ( "currentNodeSummary" ) ;
331311 return ;
332312 }
333- args [ i ] = atob ( arg ) ;
334- } ) ;
335- methodMeta ( $container , args ) ;
336- } else if ( method === "table" ) {
337- // console.log('table', args[1], args[0]);
338- $ . each ( args [ 2 ] , function ( i , col ) {
339- args [ 2 ] [ i ] = atob ( col ) ;
340- } ) ;
341- $table = this . methodTable ( args [ 0 ] , atob ( args [ 1 ] ) , args [ 2 ] , "m_table table-bordered sortable" ) ;
342- // $table.debugEnhance();
343- $currentNode . append ( $table ) ;
344- } else if ( method === "trace" ) {
345- $table = this . methodTable ( args [ 0 ] , "trace" , [ "file" , "line" , "function" ] , "m_trace table-bordered" ) ;
346- $currentNode . append ( $table ) ;
347- } else {
348- if ( [ "error" , "warn" ] . indexOf ( method ) > - 1 ) {
349- // console.log('meta', meta);
350- if ( meta . file ) {
351- attribs . title = meta . file + ': line ' + meta . line ;
313+ $toggle = $currentNode . prev ( ) ;
314+ // console.info('groupEnd', $toggle.text());
315+ if ( ! $currentNode . is ( ".debug-content" ) ) {
316+ $container . data ( "currentNode" , $currentNode . parent ( ) ) ;
352317 }
353- /*
354- update panel header to empasize error
355- */
356- if ( meta . errorCat ) {
357- // console.warn('errorCat', meta.errorCat);
358- attribs . class += ' error-' + meta . errorCat ;
359- if ( method == "error" ) {
360- // console.log('panel-danger');
361- $container . addClass ( "panel-danger" ) ;
362- $container . removeClass ( 'panel-warning' ) ; // could keep it.. but lets remove ambiguity
363- } else if ( ! $container . hasClass ( "panel-danger" ) ) {
364- // console.log('panel warning');
365- $container . addClass ( "panel-warning" ) ;
366- }
367- $container . removeClass ( 'panel-default' ) ;
318+ if ( $toggle . hasClass ( "empty" ) && $toggle . hasClass ( "hide-if-empty" ) ) {
319+ $toggle . remove ( ) ;
320+ $currentNode . remove ( ) ;
368321 }
369- }
370- hasSubs = false ;
371- if ( [ 'error' , 'info' , 'log' , 'warn' ] . indexOf ( method ) > - 1 && typeof args [ 0 ] == "string" && args . length > 1 ) {
372- args = processSubstitutions ( args , hasSubs ) ;
373- }
374- if ( hasSubs ) {
375- glue = '' ;
322+ if ( $toggle . is ( ":visible" ) ) {
323+ $toggle . debugEnhance ( ) ;
324+ }
325+ } else if ( method == "groupUncollapse" ) {
326+ // console.log('expand');
327+ $toggleNodes = $currentNode . parentsUntil ( ".debug-header, .debug-content" ) . add ( $currentNode ) . prev ( ) ;
328+ $toggleNodes . removeClass ( "collapsed" ) . addClass ( "expanded" ) ;
329+ } else if ( method === "meta" ) {
330+ $ . each ( args , function ( i , arg ) {
331+ if ( typeof arg != "string" ) {
332+ return ;
333+ }
334+ args [ i ] = atob ( arg ) ;
335+ } ) ;
336+ methodMeta ( $container , args ) ;
337+ } else if ( method === "table" ) {
338+ // console.log('table', args[1], args[0]);
339+ $ . each ( args [ 2 ] , function ( i , col ) {
340+ args [ 2 ] [ i ] = atob ( col ) ;
341+ } ) ;
342+ $table = this . methodTable ( args [ 0 ] , atob ( args [ 1 ] ) , args [ 2 ] , "m_table table-bordered sortable" ) ;
343+ // $table.debugEnhance();
344+ $currentNode . append ( $table ) ;
345+ } else if ( method === "trace" ) {
346+ $table = this . methodTable ( args [ 0 ] , "trace" , [ "file" , "line" , "function" ] , "m_trace table-bordered" ) ;
347+ $currentNode . append ( $table ) ;
376348 } else {
377- if ( args . length == 2 && typeof args [ 0 ] == "string" ) {
378- glue = ' = ' ;
349+ if ( [ "error" , "warn" ] . indexOf ( method ) > - 1 ) {
350+ // console.log('meta', meta);
351+ if ( meta . file ) {
352+ attribs . title = meta . file + ': line ' + meta . line ;
353+ }
354+ /*
355+ update panel header to empasize error
356+ */
357+ if ( meta . errorCat ) {
358+ // console.warn('errorCat', meta.errorCat);
359+ attribs . class += ' error-' + meta . errorCat ;
360+ if ( method == "error" ) {
361+ // console.log('panel-danger');
362+ $container . addClass ( "panel-danger" ) ;
363+ $container . removeClass ( 'panel-warning' ) ; // could keep it.. but lets remove ambiguity
364+ } else if ( ! $container . hasClass ( "panel-danger" ) ) {
365+ // console.log('panel warning');
366+ $container . addClass ( "panel-warning" ) ;
367+ }
368+ $container . removeClass ( 'panel-default' ) ;
369+ }
379370 }
380- for ( i = 0 , numArgs = args . length ; i < numArgs ; i ++ ) {
381- arg = args [ i ] ;
382- if ( i > 0 || typeof arg != "string" ) {
383- args [ i ] = module . dump ( arg , true ) ;
384- } else {
385- args [ i ] = module . dump ( arg , false ) ;
371+ hasSubs = false ;
372+ if ( [ 'error' , 'info' , 'log' , 'warn' ] . indexOf ( method ) > - 1 && typeof args [ 0 ] == "string" && args . length > 1 ) {
373+ args = processSubstitutions ( args , hasSubs ) ;
374+ }
375+ if ( hasSubs ) {
376+ glue = '' ;
377+ } else {
378+ if ( args . length == 2 && typeof args [ 0 ] == "string" ) {
379+ glue = ' = ' ;
380+ }
381+ for ( i = 0 , numArgs = args . length ; i < numArgs ; i ++ ) {
382+ arg = args [ i ] ;
383+ if ( i > 0 || typeof arg != "string" ) {
384+ args [ i ] = module . dump ( arg , true ) ;
385+ } else {
386+ args [ i ] = module . dump ( arg , false ) ;
387+ }
386388 }
387389 }
390+ $node = $ ( "<div>" ) . addClass ( attribs . class ) . html ( args . join ( glue ) ) ;
391+ if ( attribs . title ) {
392+ $node . prop ( 'title' , attribs . title ) ;
393+ }
394+ if ( method == "error" && meta . backtrace && meta . backtrace . length > 1 ) {
395+ // console.warn("have backtrace");
396+ $table = this . methodTable ( meta . backtrace , "trace" , [ "file" , "line" , "function" ] , "trace table-bordered" ) ;
397+ $node . append ( $table ) ;
398+ }
399+ $currentNode . append ( $node ) ;
400+ if ( $node . is ( ':visible' ) ) {
401+ $node . debugEnhance ( ) ;
402+ }
388403 }
389- $node = $ ( "<div>" ) . addClass ( attribs . class ) . html ( args . join ( glue ) ) ;
390- if ( attribs . title ) {
391- $node . prop ( 'title' , attribs . title ) ;
392- }
393- if ( method == "error" && meta . backtrace && meta . backtrace . length > 1 ) {
394- // console.warn("have backtrace");
395- $table = this . methodTable ( meta . backtrace , "trace" , [ "file" , "line" , "function" ] , "trace table-bordered" ) ;
396- $node . append ( $table ) ;
397- }
398- $currentNode . append ( $node ) ;
399- if ( $node . is ( ':visible' ) ) {
400- $node . debugEnhance ( ) ;
404+ if ( $node ) {
405+ $node . closest ( ".m_group" ) . prev ( ) . removeClass ( "empty" ) ;
401406 }
402- }
403- if ( $node ) {
404- $node . closest ( ".m_group" ) . prev ( ) . removeClass ( "empty" ) ;
407+ } catch ( err ) {
408+ module . outputLogEntry ( 'error' , [
409+ btoa ( "%cDebugWampClient: %cerror processing %c" + method + "()" ) ,
410+ btoa ( "font-weight:bold;" ) ,
411+ "" ,
412+ btoa ( "font-family:monospace;"
413+ ) ] , meta ) ;
405414 }
406415 } ;
407416
0 commit comments