@@ -25,6 +25,7 @@ import { JerryDebuggerClient } from './JerryDebuggerClient';
25
25
26
26
export type CompressedPointer = number ;
27
27
export type ByteCodeOffset = number ;
28
+ export type LoggerFunction = ( message : any ) => void ;
28
29
29
30
export interface ParserStackFrame {
30
31
isFunc : boolean ;
@@ -121,8 +122,11 @@ export class JerryDebugProtocolHandler {
121
122
private nextBreakpointIndex : number = 0 ;
122
123
private waitForSourceEnabled : boolean = false ;
123
124
124
- constructor ( delegate : JerryDebugProtocolDelegate ) {
125
+ private log : LoggerFunction ;
126
+
127
+ constructor ( delegate : JerryDebugProtocolDelegate , log ?: LoggerFunction ) {
125
128
this . delegate = delegate ;
129
+ this . log = log || < any > ( ( ) => { } ) ;
126
130
127
131
this . byteConfig = {
128
132
cpointerSize : 0 ,
@@ -448,9 +452,9 @@ export class JerryDebugProtocolHandler {
448
452
const breakpoint = breakpointRef . breakpoint ;
449
453
450
454
if ( data [ 0 ] === SP . SERVER . JERRY_DEBUGGER_EXCEPTION_HIT ) {
451
- console . log ( 'Exception throw detected' ) ;
455
+ this . log ( 'Exception throw detected' ) ;
452
456
if ( this . exceptionData ) {
453
- console . log ( ' Exception hint:' , cesu8ToString ( this . exceptionData ) ) ;
457
+ this . log ( ` Exception hint: ${ cesu8ToString ( this . exceptionData ) } ` ) ;
454
458
this . exceptionData = undefined ;
455
459
}
456
460
}
@@ -464,7 +468,7 @@ export class JerryDebugProtocolHandler {
464
468
}
465
469
466
470
const atAround = breakpointRef . exact ? 'at' : 'around' ;
467
- console . log ( `Stopped ${ atAround } ${ breakpointInfo } ${ breakpoint } ` ) ;
471
+ this . log ( `Stopped ${ atAround } ${ breakpointInfo } ${ breakpoint } ` ) ;
468
472
469
473
// TODO: handle exception case differently
470
474
if ( this . delegate . onBreakpointHit ) {
@@ -615,12 +619,12 @@ export class JerryDebugProtocolHandler {
615
619
logPacket ( description : string , ignorable : boolean = false ) {
616
620
// certain packets are ignored while evals are pending
617
621
const ignored = ( ignorable && this . evalsPending ) ? 'Ignored: ' : '' ;
618
- console . log ( `[${ ignored } ${ description } ] ` ) ;
622
+ this . log ( `[Protocol Handler] ${ ignored } ${ description } ` ) ;
619
623
}
620
624
621
625
private abort ( message : string ) {
622
626
if ( this . delegate . onError ) {
623
- console . log ( ' Abort:' , message ) ;
627
+ this . log ( ` Abort: ${ message } ` ) ;
624
628
this . delegate . onError ( 0 , message ) ;
625
629
}
626
630
}
0 commit comments