@@ -53,25 +53,21 @@ export class LogWatcher {
5353 if ( Date . now ( ) - this . logProcessedTimestamp < 1000 ) { return ; } // reduce frequency of log file I/O.
5454 const logs = await logsForLatestSession ( e . fsPath ) ;
5555 const errors = collectErrorsSince ( logs , this . logProcessedTimestamp ) ;
56- const consentToCollectLogs = vscode . workspace . getConfiguration ( "java" ) . get < boolean > ( "help.collectErrorLog" ) ;
56+ const consentToCollectLogs = vscode . workspace . getConfiguration ( "java" ) . get < boolean > ( "help.collectErrorLog" ) ?? false ;
5757 if ( errors ) {
5858 errors . forEach ( e => {
59- if ( consentToCollectLogs ) {
60- sendInfo ( "" , {
61- name : "jdtls-error" ,
62- error : e . message ,
63- stack : e . stack ! ,
64- timestamp : e . timestamp ! . toString ( )
65- } ) ;
66- } else {
67- const { message, tags} = redact ( e . message ) ;
68- sendInfo ( "" , {
69- name : "jdtls-error" ,
70- error : message ,
71- tags : tags . join ( "," ) ,
72- timestamp : e . timestamp ! . toString ( )
73- } )
59+ const { message, tags, hash} = redact ( e . message , consentToCollectLogs ) ;
60+ const infoBody : { [ key : string ] : any } = {
61+ name : "jdtls-error" ,
62+ error : message ,
63+ tags : tags . join ( "," ) ,
64+ hash : hash ,
65+ timestamp : e . timestamp ! . toString ( )
66+ } ;
67+ if ( consentToCollectLogs && e . stack ) {
68+ infoBody . stack = e . stack ;
7469 }
70+ sendInfo ( "" , infoBody ) ;
7571 } )
7672 }
7773 this . logProcessedTimestamp = Date . now ( ) ;
@@ -111,26 +107,21 @@ export class LogWatcher {
111107 if ( this . serverLogUri ) {
112108 const logs = await logsForLatestSession ( path . join ( this . serverLogUri ?. fsPath , ".log" ) ) ;
113109 const errors = collectErrors ( logs ) ;
114- const consentToCollectLogs = vscode . workspace . getConfiguration ( "java" ) . get < boolean > ( "help.collectErrorLog" ) ;
110+ const consentToCollectLogs = vscode . workspace . getConfiguration ( "java" ) . get < boolean > ( "help.collectErrorLog" ) ?? false ;
115111 if ( errors ) {
116112 errors . forEach ( e => {
117- if ( consentToCollectLogs ) {
118- sendInfo ( "" , {
119- name : "jdtls-error-in-crashed-session" ,
120- error : e . message ,
121- stack : e . stack ! ,
122- timestamp : e . timestamp ! . toString ( )
123- } )
124- } else {
125- const { message, tags } = redact ( e . message ) ;
126- sendInfo ( "" , {
127- name : "jdtls-error-in-crashed-session" ,
128- error : message ,
129- tags : tags . join ( "," ) ,
130- timestamp : e . timestamp ! . toString ( )
131- } )
113+ const { message, tags, hash} = redact ( e . message , consentToCollectLogs ) ;
114+ const infoBody : { [ key : string ] : any } = {
115+ name : "jdtls-error-in-crashed-session" ,
116+ error : message ,
117+ tags : tags . join ( "," ) ,
118+ hash : hash ,
119+ timestamp : e . timestamp ! . toString ( )
120+ } ;
121+ if ( consentToCollectLogs && e . stack ) {
122+ infoBody . stack = e . stack ;
132123 }
133-
124+ sendInfo ( "" , infoBody ) ;
134125 } )
135126 }
136127 }
0 commit comments