Include subservers logfiles in YcmToggleLogs

This commit is contained in:
micbou 2017-01-19 01:07:32 +01:00
parent dc05227b02
commit ab758e4c64
No known key found for this signature in database
GPG Key ID: C7E8FD1F3BDA1E05
4 changed files with 28 additions and 13 deletions

View File

@ -40,10 +40,10 @@ class DebugInfoRequest( BaseRequest ):
def Response( self ): def Response( self ):
return _FormatDebugInfoResponse( self._response ) return self._response
def _FormatDebugInfoResponse( response ): def FormatDebugInfoResponse( response ):
if not response: if not response:
return 'Server errored, no debug info from server\n' return 'Server errored, no debug info from server\n'
message = _FormatYcmdDebugInfo( response ) message = _FormatYcmdDebugInfo( response )

View File

@ -26,7 +26,7 @@ from builtins import * # noqa
from copy import deepcopy from copy import deepcopy
from hamcrest import assert_that, contains_string, equal_to from hamcrest import assert_that, contains_string, equal_to
from ycm.client.debug_info_request import _FormatDebugInfoResponse from ycm.client.debug_info_request import FormatDebugInfoResponse
GENERIC_RESPONSE = { GENERIC_RESPONSE = {
@ -76,7 +76,7 @@ GENERIC_RESPONSE = {
def FormatDebugInfoResponse_NoResponse_test(): def FormatDebugInfoResponse_NoResponse_test():
assert_that( assert_that(
_FormatDebugInfoResponse( None ), FormatDebugInfoResponse( None ),
equal_to( 'Server errored, no debug info from server\n' ) equal_to( 'Server errored, no debug info from server\n' )
) )
@ -88,7 +88,7 @@ def FormatDebugInfoResponse_NoExtraConf_test():
'path': None 'path': None
} ) } )
assert_that( assert_that(
_FormatDebugInfoResponse( response ), FormatDebugInfoResponse( response ),
contains_string( contains_string(
'No extra configuration file found\n' 'No extra configuration file found\n'
) )
@ -102,7 +102,7 @@ def FormatDebugInfoResponse_ExtraConfFoundButNotLoaded_test():
'path': '/path/to/extra/conf' 'path': '/path/to/extra/conf'
} ) } )
assert_that( assert_that(
_FormatDebugInfoResponse( response ), FormatDebugInfoResponse( response ),
contains_string( contains_string(
'Extra configuration file found but not loaded\n' 'Extra configuration file found but not loaded\n'
'Extra configuration path: /path/to/extra/conf\n' 'Extra configuration path: /path/to/extra/conf\n'
@ -117,7 +117,7 @@ def FormatDebugInfoResponse_ExtraConfFoundAndLoaded_test():
'path': '/path/to/extra/conf' 'path': '/path/to/extra/conf'
} ) } )
assert_that( assert_that(
_FormatDebugInfoResponse( response ), FormatDebugInfoResponse( response ),
contains_string( contains_string(
'Extra configuration file found and loaded\n' 'Extra configuration file found and loaded\n'
'Extra configuration path: /path/to/extra/conf\n' 'Extra configuration path: /path/to/extra/conf\n'
@ -128,7 +128,7 @@ def FormatDebugInfoResponse_ExtraConfFoundAndLoaded_test():
def FormatDebugInfoResponse_Completer_ServerRunningWithHost_test(): def FormatDebugInfoResponse_Completer_ServerRunningWithHost_test():
response = deepcopy( GENERIC_RESPONSE ) response = deepcopy( GENERIC_RESPONSE )
assert_that( assert_that(
_FormatDebugInfoResponse( response ), FormatDebugInfoResponse( response ),
contains_string( contains_string(
'Completer name completer debug information:\n' 'Completer name completer debug information:\n'
' Server name running at: http://127.0.0.1:1234\n' ' Server name running at: http://127.0.0.1:1234\n'
@ -150,7 +150,7 @@ def FormatDebugInfoResponse_Completer_ServerRunningWithoutHost_test():
'port': None 'port': None
} ) } )
assert_that( assert_that(
_FormatDebugInfoResponse( response ), FormatDebugInfoResponse( response ),
contains_string( contains_string(
'Completer name completer debug information:\n' 'Completer name completer debug information:\n'
' Server name running\n' ' Server name running\n'
@ -172,7 +172,7 @@ def FormatDebugInfoResponse_Completer_ServerNotRunningWithNoLogfiles_test():
'logfiles': [] 'logfiles': []
} ) } )
assert_that( assert_that(
_FormatDebugInfoResponse( response ), FormatDebugInfoResponse( response ),
contains_string( contains_string(
'Completer name completer debug information:\n' 'Completer name completer debug information:\n'
' Server name not running\n' ' Server name not running\n'

View File

@ -227,6 +227,10 @@ def YouCompleteMe_ToggleLogs_WithParameters_test( ycm,
@YouCompleteMeInstance() @YouCompleteMeInstance()
@patch( 'ycm.vimsupport.PostVimMessage' ) @patch( 'ycm.vimsupport.PostVimMessage' )
def YouCompleteMe_ToggleLogs_WithoutParameters_test( ycm, post_vim_message ): def YouCompleteMe_ToggleLogs_WithoutParameters_test( ycm, post_vim_message ):
# We test on a Python buffer because the Python completer has subserver
# logfiles.
python_buffer = VimBuffer( 'buffer.py', filetype = 'python' )
with MockVimBuffers( [ python_buffer ], python_buffer ):
ycm.ToggleLogs() ycm.ToggleLogs()
assert_that( assert_that(
@ -234,6 +238,8 @@ def YouCompleteMe_ToggleLogs_WithoutParameters_test( ycm, post_vim_message ):
post_vim_message.call_args[ 0 ][ 0 ], post_vim_message.call_args[ 0 ][ 0 ],
matches_regexp( matches_regexp(
'Available logfiles are:\n' 'Available logfiles are:\n'
'jedihttp_\d+_stderr_.+.log\n'
'jedihttp_\d+_stdout_.+.log\n'
'ycm_.+.log\n' 'ycm_.+.log\n'
'ycmd_\d+_stderr_.+.log\n' 'ycmd_\d+_stderr_.+.log\n'
'ycmd_\d+_stdout_.+.log' ) 'ycmd_\d+_stdout_.+.log' )

View File

@ -48,7 +48,8 @@ from ycm.client.completer_available_request import SendCompleterAvailableRequest
from ycm.client.command_request import SendCommandRequest from ycm.client.command_request import SendCommandRequest
from ycm.client.completion_request import ( CompletionRequest, from ycm.client.completion_request import ( CompletionRequest,
ConvertCompletionDataToVimData ) ConvertCompletionDataToVimData )
from ycm.client.debug_info_request import SendDebugInfoRequest from ycm.client.debug_info_request import ( SendDebugInfoRequest,
FormatDebugInfoResponse )
from ycm.client.omni_completion_request import OmniCompletionRequest from ycm.client.omni_completion_request import OmniCompletionRequest
from ycm.client.event_notification import ( SendEventNotificationAsync, from ycm.client.event_notification import ( SendEventNotificationAsync,
EventNotification ) EventNotification )
@ -648,7 +649,7 @@ class YouCompleteMe( object ):
if self._client_logfile: if self._client_logfile:
debug_info += 'Client logfile: {0}\n'.format( self._client_logfile ) debug_info += 'Client logfile: {0}\n'.format( self._client_logfile )
if self.IsServerAlive(): if self.IsServerAlive():
debug_info += SendDebugInfoRequest() debug_info += FormatDebugInfoResponse( SendDebugInfoRequest() )
else: else:
debug_info += 'Server crashed, no debug info from server\n' debug_info += 'Server crashed, no debug info from server\n'
debug_info += ( debug_info += (
@ -667,6 +668,14 @@ class YouCompleteMe( object ):
logfiles_list = [ self._client_logfile, logfiles_list = [ self._client_logfile,
self._server_stdout, self._server_stdout,
self._server_stderr ] self._server_stderr ]
if self.IsServerAlive():
debug_info = SendDebugInfoRequest()
completer = debug_info[ 'completer' ]
if completer:
for server in completer[ 'servers' ]:
logfiles_list.extend( server[ 'logfiles' ] )
logfiles = {} logfiles = {}
for logfile in logfiles_list: for logfile in logfiles_list:
logfiles[ os.path.basename( logfile ) ] = logfile logfiles[ os.path.basename( logfile ) ] = logfile