@@ -369,6 +369,8 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
369369
370370 // Register commands here to make it available even when the language client fails
371371 context . subscriptions . push ( commands . registerCommand ( Commands . OPEN_SERVER_LOG , ( column : ViewColumn ) => openServerLogFile ( workspacePath , column ) ) ) ;
372+ context . subscriptions . push ( commands . registerCommand ( Commands . OPEN_SERVER_STDOUT_LOG , ( column : ViewColumn ) => openRollingServerLogFile ( workspacePath , '.out-jdt.ls' , column ) ) ) ;
373+ context . subscriptions . push ( commands . registerCommand ( Commands . OPEN_SERVER_STDERR_LOG , ( column : ViewColumn ) => openRollingServerLogFile ( workspacePath , '.error-jdt.ls' , column ) ) ) ;
372374
373375 context . subscriptions . push ( commands . registerCommand ( Commands . OPEN_CLIENT_LOG , ( column : ViewColumn ) => openClientLogFile ( clientLogFile , column ) ) ) ;
374376
@@ -734,6 +736,25 @@ function openServerLogFile(workspacePath, column: ViewColumn = ViewColumn.Active
734736 return openLogFile ( serverLogFile , 'Could not open Java Language Server log file' , column ) ;
735737}
736738
739+ function openRollingServerLogFile ( workspacePath , filename , column : ViewColumn = ViewColumn . Active ) : Thenable < boolean > {
740+ return new Promise ( ( resolve ) => {
741+ const dirname = path . join ( workspacePath , '.metadata' ) ;
742+
743+ // find out the newest one
744+ glob ( filename + '-*' , { cwd : dirname } , ( err , files ) => {
745+ if ( ! err && files . length > 0 ) {
746+ files . sort ( ) ;
747+
748+ const logFile = path . join ( dirname , files [ files . length - 1 ] ) ;
749+ openLogFile ( logFile , `Could not open Java Language Server log file ${ filename } ` , column ) . then ( ( result ) => resolve ( result ) ) ;
750+ } else {
751+ window . showWarningMessage ( `Could not find Java Language Server log file ${ filename } in ${ dirname } ` ) ;
752+ resolve ( false ) ;
753+ }
754+ } ) ;
755+ } ) ;
756+ }
757+
737758function openClientLogFile ( logFile : string , column : ViewColumn = ViewColumn . Active ) : Thenable < boolean > {
738759 return new Promise ( ( resolve ) => {
739760 const filename = path . basename ( logFile ) ;
@@ -765,7 +786,9 @@ function openClientLogFile(logFile: string, column: ViewColumn = ViewColumn.Acti
765786
766787async function openLogs ( ) {
767788 await commands . executeCommand ( Commands . OPEN_CLIENT_LOG , ViewColumn . One ) ;
768- await commands . executeCommand ( Commands . OPEN_SERVER_LOG , ViewColumn . Two ) ;
789+ await commands . executeCommand ( Commands . OPEN_SERVER_LOG , ViewColumn . One ) ;
790+ await commands . executeCommand ( Commands . OPEN_SERVER_STDOUT_LOG , ViewColumn . One ) ;
791+ await commands . executeCommand ( Commands . OPEN_SERVER_STDERR_LOG , ViewColumn . One ) ;
769792}
770793
771794function openLogFile ( logFile , openingFailureWarning : string , column : ViewColumn = ViewColumn . Active ) : Thenable < boolean > {
@@ -778,7 +801,7 @@ function openLogFile(logFile, openingFailureWarning: string, column: ViewColumn
778801 if ( ! doc ) {
779802 return false ;
780803 }
781- return window . showTextDocument ( doc , column )
804+ return window . showTextDocument ( doc , { viewColumn : column , preview : false } )
782805 . then ( editor => ! ! editor ) ;
783806 } , ( ) => false )
784807 . then ( didOpen => {
0 commit comments