Print server stderr to the GUI

This commit is contained in:
Ben Jackson 2019-01-12 15:12:52 +00:00
commit e573c2fd9f
3 changed files with 20 additions and 7 deletions

View file

@ -189,6 +189,11 @@ class DebugSession( object ):
if self._connection:
self._connection.OnData( data )
def OnServerStderr( self, data ):
self._logger.info( "Server stderr: %s", data )
if self._outputView:
self._outputView.ServerEcho( data )
def OnRequestTimeout( self, timer_id ):
if self._connection:
self._connection.OnRequestTimeout( timer_id )

View file

@ -42,19 +42,25 @@ class OutputView( object ):
self.ShowOutput( 'Console' )
def ServerEcho( self, text ):
self._Print( 'server', text.splitlines() )
def OnOutput( self, event ):
category = CategoryToBuffer( event.get( 'category' ) or 'output' )
text_lines = event[ 'output' ].splitlines()
if 'data' in event:
text_lines.extend( json.dumps( event[ 'data' ],
indent = 2 ).splitlines() )
self._Print( category, text_lines )
def _Print( self, category, text_lines ):
if category not in self._buffers:
self._CreateBuffer( category )
buf = self._buffers[ category ]
with utils.ModifiableScratchBuffer( buf ):
utils.AppendToBuffer( buf, event[ 'output' ].splitlines() )
if 'data' in event:
utils.AppendToBuffer( buf,
json.dumps( event[ 'data' ],
indent = 2 ).splitlines() )
utils.AppendToBuffer( buf, text_lines )
# Scroll the buffer
with utils.RestoreCurrentWindow():