@@ -57,6 +57,8 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener {
5757 // Try to connect to this notebook
5858 const config = await this . connect ( notebook ) ;
5959 if ( config ) {
60+ traceInfo ( 'connected to notebook during debugging' ) ;
61+
6062 // First check if this is a live share session. Skip debugging attach on the guest
6163 // tslint:disable-next-line: no-any
6264 const hasRole = ( notebook as any ) as ILiveShareHasRole ;
@@ -75,6 +77,8 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener {
7577 const importResults = await this . executeSilently ( notebook , `import ptvsd\nptvsd.wait_for_attach()` ) ;
7678 if ( importResults . length === 0 || importResults [ 0 ] . state === CellState . error ) {
7779 traceWarning ( 'PTVSD not found in path.' ) ;
80+ } else {
81+ this . traceCellResults ( 'import startup' , importResults ) ;
7882 }
7983
8084 // Then enable tracing
@@ -119,6 +123,22 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener {
119123 }
120124 }
121125
126+ private traceCellResults ( prefix : string , results : ICell [ ] ) {
127+ if ( results . length > 0 && results [ 0 ] . data . cell_type === 'code' ) {
128+ const cell = results [ 0 ] . data as nbformat . ICodeCell ;
129+ const error = cell . outputs [ 0 ] . evalue ;
130+ if ( error ) {
131+ traceError ( `${ prefix } Error : ${ error } ` ) ;
132+ } else {
133+ const data = cell . outputs [ 0 ] . data ;
134+ const text = cell . outputs [ 0 ] . text ;
135+ traceInfo ( `${ prefix } Output: ${ text || JSON . stringify ( data ) } ` ) ;
136+ }
137+ } else {
138+ traceInfo ( `${ prefix } no output.` ) ;
139+ }
140+ }
141+
122142 private async connect ( notebook : INotebook ) : Promise < DebugConfiguration | undefined > {
123143 // If we already have configuration, we're already attached, don't do it again.
124144 let result = this . configs . get ( notebook . resource . toString ( ) ) ;
@@ -201,7 +221,8 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener {
201221 const ptvsdPathList = this . calculatePtvsdPathList ( notebook ) ;
202222
203223 if ( ptvsdPathList && ptvsdPathList . length > 0 ) {
204- await this . executeSilently ( notebook , `import sys\r\nsys.path.extend([${ ptvsdPathList } ])\r\nsys.path` ) ;
224+ const result = await this . executeSilently ( notebook , `import sys\r\nsys.path.extend([${ ptvsdPathList } ])\r\nsys.path` ) ;
225+ this . traceCellResults ( 'Appending paths' , result ) ;
205226 }
206227 }
207228
@@ -243,6 +264,7 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener {
243264
244265 private parsePtvsdVersionInfo ( cells : ICell [ ] ) : IPtvsdVersion | undefined {
245266 if ( cells . length < 1 || cells [ 0 ] . state !== CellState . finished ) {
267+ this . traceCellResults ( 'parsePtvsdVersionInfo' , cells ) ;
246268 return undefined ;
247269 }
248270
@@ -262,6 +284,8 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener {
262284 }
263285 }
264286
287+ this . traceCellResults ( 'parsingPtvsdVersionInfo' , cells ) ;
288+
265289 return undefined ;
266290 }
267291
@@ -292,6 +316,7 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener {
292316 private async installPtvsd ( notebook : INotebook ) : Promise < void > {
293317 // tslint:disable-next-line:no-multiline-string
294318 const ptvsdInstallResults = await this . executeSilently ( notebook , `import sys\r\n!{sys.executable} -m pip install -U ptvsd` ) ;
319+ traceInfo ( 'Installing ptvsd' ) ;
295320
296321 if ( ptvsdInstallResults . length > 0 ) {
297322 const installResultsString = this . extractOutput ( ptvsdInstallResults [ 0 ] ) ;
@@ -302,7 +327,7 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener {
302327 return ;
303328 }
304329 }
305-
330+ this . traceCellResults ( 'Installing PTVSD' , ptvsdInstallResults ) ;
306331 sendTelemetryEvent ( Telemetry . PtvsdInstallFailed ) ;
307332 traceError ( 'Failed to install ptvsd' ) ;
308333 // Failed to install ptvsd, throw to exit debugging
0 commit comments