Skip to content

Commit

Permalink
Add client logfile
Browse files Browse the repository at this point in the history
  • Loading branch information
micbou committed Nov 19, 2016
1 parent fbe53de commit b93c1fd
Show file tree
Hide file tree
Showing 12 changed files with 469 additions and 237 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE.md
Expand Up @@ -12,8 +12,8 @@ the brackets) _before_ filing your issue:**
search.][search])
- [ ] If filing a bug report, I have included the output of `vim --version`.
- [ ] If filing a bug report, I have included the output of `:YcmDebugInfo`.
- [ ] If filing a bug report, I have included the output of
`:YcmToggleLogs stderr`.
- [ ] If filing a bug report, I have attached the contents of the logfiles using
the `:YcmToggleLogs` command.
- [ ] If filing a bug report, I have included which OS (including specific OS
version) I am using.
- [ ] If filing a bug report, I have included a minimal test case that reproduces
Expand Down
16 changes: 9 additions & 7 deletions CONTRIBUTING.md
Expand Up @@ -45,16 +45,16 @@ Here are the things you should do when creating an issue:
1. **Write a step-by-step procedure that when performed repeatedly reproduces
your issue.** If we can't reproduce the issue, then we can't fix it. It's
that simple.
2. Put the following options in your vimrc:

2. Add the output of [the `:YcmDebugInfo` command][ycm-debug-info-command].
3. Put the following options in your vimrc:
```viml
let g:ycm_server_keep_logfiles = 1
let g:ycm_server_log_level = 'debug'
let g:ycm_keep_logfiles = 1
let g:ycm_log_level = 'debug'
```

Run `:YcmToggleLogs stderr` in vim to open the logfile. Attach the contents
of this file to your issue.
3. Add the output of the `:YcmDebugInfo` command.
Reproduce your issue and attach the contents of the logfiles. Use [the
`:YcmToggleLogs` command][ycm-toggle-logs-command] to directly open them in
Vim.
4. **Create a test case for your issue**. This is critical. Don't talk about how
"when I have X in my file" or similar, _create a file with X in it_ and put
the contents inside code blocks in your issue description. Try to make this
Expand Down Expand Up @@ -112,3 +112,5 @@ Creating good pull requests
[build-bots]: https://travis-ci.org/Valloric/YouCompleteMe
[ycm-users]: https://groups.google.com/forum/?hl=en#!forum/ycm-users
[gitter]: https://gitter.im/Valloric/YouCompleteMe
[ycm-debug-info-command]: https://github.com/Valloric/YouCompleteMe#the-ycmdebuginfo-command
[ycm-toggle-logs-command]: https://github.com/Valloric/YouCompleteMe#the-ycmtogglelogs-command
34 changes: 16 additions & 18 deletions README.md
Expand Up @@ -1152,12 +1152,9 @@ completion engine.

### The `:YcmToggleLogs` command

This command automatically opens in windows the stdout and stderr logfiles
written by the [ycmd server][ycmd]. If one or both logfiles are already opened,
they are automatically closed. `stderr` or `stdout` can be specified as an
argument of this command to only open the corresponding logfile instead of both.
If this logfile is already opened, it will be closed. Only for debugging
purpose.
This command opens in separate windows the logfiles given as arguments or closes
them if they are already open in the editor. When no argument is given, list the
available logfiles. Only for debugging purpose.

### The `:YcmCompleter` command

Expand Down Expand Up @@ -2022,23 +2019,24 @@ Default: `''`
let g:ycm_server_python_interpreter = ''
```

### The `g:ycm_server_keep_logfiles` option
### The `g:ycm_keep_logfiles` option

When this option is set to `1`, the [ycmd completion server][ycmd] will keep the
logfiles around after shutting down (they are deleted on shutdown by default).
When this option is set to `1`, YCM and the [ycmd completion server][ycmd] will
keep the logfiles around after shutting down (they are deleted on shutdown by
default).

To see where the logfiles are, call `:YcmDebugInfo`.

Default: `0`

```viml
let g:ycm_server_keep_logfiles = 0
let g:ycm_keep_logfiles = 0
```

### The `g:ycm_server_log_level` option
### The `g:ycm_log_level` option

The logging level that the [ycmd completion server][ycmd] uses. Valid values are
the following, from most verbose to least verbose:
The logging level that YCM and the [ycmd completion server][ycmd] use. Valid
values are the following, from most verbose to least verbose:
- `debug`
- `info`
- `warning`
Expand All @@ -2050,7 +2048,7 @@ Note that `debug` is _very_ verbose.
Default: `info`

```viml
let g:ycm_server_log_level = 'info'
let g:ycm_log_level = 'info'
```

### The `g:ycm_auto_start_csharp_server` option
Expand Down Expand Up @@ -2499,10 +2497,10 @@ the message log if it encounters problems. It's likely you misconfigured
something and YCM is complaining about it.

Also, you may want to run the `:YcmDebugInfo` command; it will make YCM spew out
various debugging information, including the [ycmd][] logfile paths and the
compile flags for the current file if the file is a C-family language file and
you have compiled in Clang support. Logfiles can be automatically opened in the
editor using the `:YcmToggleLogs` command.
various debugging information, including the YCM and [ycmd][] logfile paths and
the compile flags for the current file if the file is a C-family language file
and you have compiled in Clang support. Logfiles can be opened in the editor
using [the `:YcmToggleLogs` command](#the-ycmtogglelogs-command).

### Sometimes it takes much longer to get semantic completions than normal

Expand Down
14 changes: 5 additions & 9 deletions autoload/youcompleteme.vim
Expand Up @@ -374,7 +374,7 @@ function! s:SetUpCommands()
command! YcmRestartServer call s:RestartServer()
command! YcmShowDetailedDiagnostic call s:ShowDetailedDiagnostic()
command! YcmDebugInfo call s:DebugInfo()
command! -nargs=? -complete=custom,youcompleteme#LogsComplete
command! -nargs=* -complete=custom,youcompleteme#LogsComplete
\ YcmToggleLogs call s:ToggleLogs(<f-args>)
command! -nargs=* -complete=custom,youcompleteme#SubCommandsComplete
\ YcmCompleter call s:CompleterCommand(<f-args>)
Expand Down Expand Up @@ -454,6 +454,7 @@ function! s:OnBufferReadPre(filename)
endif
endfunction


function! s:OnBufferRead()
" We need to do this even when we are not allowed to complete in the current
" buffer because we might be allowed to complete in the future! The canonical
Expand Down Expand Up @@ -787,11 +788,7 @@ endfunction


function! s:ToggleLogs(...)
let stderr = a:0 == 0 || a:1 !=? 'stdout'
let stdout = a:0 == 0 || a:1 !=? 'stderr'
exec s:python_command "ycm_state.ToggleLogs("
\ "stdout = vimsupport.GetBoolValue( 'l:stdout' ),"
\ "stderr = vimsupport.GetBoolValue( 'l:stderr' ) )"
exec s:python_command "ycm_state.ToggleLogs( *vim.eval( 'a:000' ) )"
endfunction


Expand Down Expand Up @@ -827,13 +824,12 @@ endfunction


function! youcompleteme#LogsComplete( arglead, cmdline, cursorpos )
return "stdout\nstderr"
return join( s:Pyeval( 'list( ycm_state.GetLogfiles() )' ), "\n" )
endfunction


function! youcompleteme#SubCommandsComplete( arglead, cmdline, cursorpos )
return join( s:Pyeval( 'ycm_state.GetDefinedSubcommands()' ),
\ "\n")
return join( s:Pyeval( 'ycm_state.GetDefinedSubcommands()' ), "\n" )
endfunction


Expand Down
38 changes: 18 additions & 20 deletions doc/youcompleteme.txt
Expand Up @@ -100,8 +100,8 @@ Contents ~
21. The |g:ycm_seed_identifiers_with_syntax| option
22. The |g:ycm_extra_conf_vim_data| option
23. The |g:ycm_server_python_interpreter| option
24. The |g:ycm_server_keep_logfiles| option
25. The |g:ycm_server_log_level| option
24. The |g:ycm_keep_logfiles| option
25. The |g:ycm_log_level| option
26. The |g:ycm_auto_start_csharp_server| option
27. The |g:ycm_auto_stop_csharp_server| option
28. The |g:ycm_csharp_server_port| option
Expand Down Expand Up @@ -1418,12 +1418,9 @@ semantic completion engine.
-------------------------------------------------------------------------------
The *:YcmToggleLogs* command

This command automatically opens in windows the stdout and stderr logfiles
written by the ycmd server [43]. If one or both logfiles are already opened,
they are automatically closed. 'stderr' or 'stdout' can be specified as an
argument of this command to only open the corresponding logfile instead of
both. If this logfile is already opened, it will be closed. Only for debugging
purpose.
This command opens in separate windows the logfiles given as arguments or
closes them if they are already open in the editor. When no argument is given,
list the available logfiles. Only for debugging purpose.

-------------------------------------------------------------------------------
The *:YcmCompleter* command
Expand Down Expand Up @@ -2285,29 +2282,30 @@ Default: "''"
let g:ycm_server_python_interpreter = ''
<
-------------------------------------------------------------------------------
The *g:ycm_server_keep_logfiles* option
The *g:ycm_keep_logfiles* option

When this option is set to '1', the ycmd completion server [43] will keep the
logfiles around after shutting down (they are deleted on shutdown by default).
When this option is set to '1', YCM and the ycmd completion server [43] will
keep the logfiles around after shutting down (they are deleted on shutdown by
default).

To see where the logfiles are, call |:YcmDebugInfo|.

Default: '0'
>
let g:ycm_server_keep_logfiles = 0
let g:ycm_keep_logfiles = 0
<
-------------------------------------------------------------------------------
The *g:ycm_server_log_level* option
The *g:ycm_log_level* option

The logging level that the ycmd completion server [43] uses. Valid values are
the following, from most verbose to least verbose: - 'debug' - 'info' -
'warning' - 'error' - 'critical'
The logging level that YCM and the ycmd completion server [43] use. Valid
values are the following, from most verbose to least verbose: - 'debug' -
'info' - 'warning' - 'error' - 'critical'

Note that 'debug' is _very_ verbose.

Default: 'info'
>
let g:ycm_server_log_level = 'info'
let g:ycm_log_level = 'info'
<
-------------------------------------------------------------------------------
The *g:ycm_auto_start_csharp_server* option
Expand Down Expand Up @@ -2741,9 +2739,9 @@ to the message log if it encounters problems. It's likely you misconfigured
something and YCM is complaining about it.

Also, you may want to run the |:YcmDebugInfo| command; it will make YCM spew
out various debugging information, including the ycmd [43] logfile paths and
the compile flags for the current file if the file is a C-family language file
and you have compiled in Clang support. Logfiles can be automatically opened in
out various debugging information, including the YCM and ycmd [43] logfile
paths and the compile flags for the current file if the file is a C-family
language file and you have compiled in Clang support. Logfiles can be opened in
the editor using the |:YcmToggleLogs| command.

-------------------------------------------------------------------------------
Expand Down
10 changes: 6 additions & 4 deletions plugin/youcompleteme.vim
Expand Up @@ -80,11 +80,13 @@ let g:ycm_key_detailed_diagnostics =
let g:ycm_cache_omnifunc =
\ get( g:, 'ycm_cache_omnifunc', 1 )

let g:ycm_server_log_level =
\ get( g:, 'ycm_server_log_level', 'info' )
let g:ycm_log_level =
\ get( g:, 'ycm_log_level',
\ get( g:, 'ycm_server_log_level', 'info' ) )

let g:ycm_server_keep_logfiles =
\ get( g:, 'ycm_server_keep_logfiles', 0 )
let g:ycm_keep_logfiles =
\ get( g:, 'ycm_keep_logfiles',
\ get( g:, 'ycm_server_keep_logfiles', 0 ) )

let g:ycm_extra_conf_vim_data =
\ get( g:, 'ycm_extra_conf_vim_data', [] )
Expand Down
18 changes: 13 additions & 5 deletions python/ycm/tests/__init__.py
Expand Up @@ -40,7 +40,8 @@
# thus are not part of default_options.json, but are required for a working
# YouCompleteMe object.
DEFAULT_CLIENT_OPTIONS = {
'server_log_level': 'info',
'log_level': 'info',
'keep_logfiles': 0,
'extra_conf_vim_data': [],
'show_diagnostics_ui': 1,
'enable_diagnostic_signs': 1,
Expand Down Expand Up @@ -80,6 +81,14 @@ def _WaitUntilReady( timeout = 5 ):
time.sleep( 0.1 )


def StopServer( ycm ):
try:
ycm.OnVimLeave()
WaitUntilProcessIsTerminated( ycm._server_popen )
except Exception:
pass


def YouCompleteMeInstance( custom_options = {} ):
"""Defines a decorator function for tests that passes a unique YouCompleteMe
instance as a parameter. This instance is initialized with the default options
Expand All @@ -92,8 +101,8 @@ def YouCompleteMeInstance( custom_options = {} ):
from ycm.tests import YouCompleteMeInstance
@YouCompleteMeInstance( { 'server_log_level': 'debug',
'server_keep_logfiles': 1 } )
@YouCompleteMeInstance( { 'log_level': 'debug',
'keep_logfiles': 1 } )
def Debug_test( ycm ):
...
"""
Expand All @@ -105,7 +114,6 @@ def Wrapper( *args, **kwargs ):
try:
test( ycm, *args, **kwargs )
finally:
ycm.OnVimLeave()
WaitUntilProcessIsTerminated( ycm._server_popen )
StopServer( ycm )
return Wrapper
return Decorator
4 changes: 2 additions & 2 deletions python/ycm/tests/test_utils.py
Expand Up @@ -176,7 +176,7 @@ def MockVimCommand( command ):

class VimBuffer( object ):
"""An object that looks like a vim.buffer object:
- |name| : full path of the buffer;
- |name| : full path of the buffer with symbolic links resolved;
- |number| : buffer number;
- |contents|: list of lines representing the buffer contents;
- |filetype|: buffer filetype. Empty string if no filetype is set;
Expand All @@ -191,7 +191,7 @@ def __init__( self, name,
modified = True,
window = None,
omnifunc = '' ):
self.name = name
self.name = os.path.realpath( name ) if name else ''
self.number = number
self.contents = contents
self.filetype = filetype
Expand Down

0 comments on commit b93c1fd

Please sign in to comment.