Optionally write OmniSharp stdout and stderr to log files

This commit is contained in:
Spencer G. Jones 2013-07-12 14:46:33 -06:00
parent a6a9fa10c3
commit 3737ca2ef4
2 changed files with 22 additions and 2 deletions

View File

@ -157,6 +157,13 @@ let g:ycm_auto_start_csharp_server =
let g:ycm_csharp_server_port =
\ get( g:, 'ycm_csharp_server_port', 2000 )
let g:ycm_csharp_server_stderr_logfile_format =
\ get( g:, 'ycm_csharp_server_stderr_logfile_format', '' )
let g:ycm_csharp_server_stdout_logfile_format =
\ get( g:, 'ycm_csharp_server_stdout_logfile_format', '' )
" On-demand loading. Let's use the autoload folder and not slow down vim's
" startup procedure.
augroup youcompletemeStart

View File

@ -108,8 +108,21 @@ class CsharpCompleter( ThreadedCompleter ):
# command has to be provided as one string for some reason
command = [ omnisharp + ' -p ' + str( self.OmniSharpPort ) + ' -s ' + solutionfile ]
with open( os.devnull, "w" ) as fnull:
subprocess.Popen( command, stdout = fnull, stderr = fnull, shell=True )
stderrLogFormat = vimsupport.GetVariableValue( "g:ycm_csharp_server_stderr_logfile_format" )
if stderrLogFormat:
fstderr = open( os.path.expanduser( stderrLogFormat.format( port=self.OmniSharpPort ) ), "w" )
else:
fstderr = open( os.devnull, "w" )
stdoutLogFormat = vimsupport.GetVariableValue( "g:ycm_csharp_server_stdout_logfile_format" )
if stdoutLogFormat:
fstdout = open( os.path.expanduser( stdoutLogFormat.format( port=self.OmniSharpPort ) ), "w" )
else:
fstdout = open( os.devnull, "w" )
with fstderr as fstderr:
with fstdout as fstdout:
subprocess.Popen( command, stdout=fstdout, stderr=fstderr, shell=True )
def _StopServer( self ):
""" Stop the OmniSharp server """