Add simple logging.

This commit is contained in:
Andy Stewart
2016-04-25 13:19:50 +01:00
parent 52d1167d7d
commit 4bed1da648
6 changed files with 28 additions and 3 deletions

View File

@@ -1,3 +1,5 @@
let s:log_file = expand('<sfile>:p:h:h:h').'/'.'gitgutter.log'
function! gitgutter#debug#debug()
" Open a scratch buffer
vsplit __GitGutter_Debug__
@@ -70,8 +72,19 @@ function! gitgutter#debug#output(text)
call append(line('$'), a:text)
endfunction
function! gitgutter#debug#log(message)
let msg = type(a:message) == 1 ? split(a:message, '\n') : a:message
call writefile(msg, 'gitgutter.log', 'a')
" assumes optional args are calling function's optional args
function! gitgutter#debug#log(message, ...)
if g:gitgutter_log
execute 'redir >> '.s:log_file
" callers excluding this function
silent echo "\n".expand('<sfile>')[:-22].':'
silent echo type(a:message) == 1 ? join(split(a:message, '\n'),"\n") : a:message
if a:0 && !empty(a:1)
for msg in a:000
silent echo type(msg) == 1 ? join(split(msg, '\n'),"\n") : msg
endfor
endif
redir END
endif
endfunction

View File

@@ -134,9 +134,11 @@ function! gitgutter#diff#run_diff(realtime, preserve_full_diff)
\ 'on_stderr': function('gitgutter#handle_diff_job'),
\ 'on_exit': function('gitgutter#handle_diff_job')
\ })
call gitgutter#debug#log('[job_id: '.job_id.'] '.cmd)
if job_id < 1
throw 'diff failed'
endif
call gitgutter#utility#pending_job(job_id)
return 'async'
else

View File

@@ -121,6 +121,8 @@ function! gitgutter#utility#using_xolox_shell()
endfunction
function! gitgutter#utility#system(cmd, ...)
call gitgutter#debug#log(a:cmd, a:000)
if gitgutter#utility#using_xolox_shell()
let options = {'command': a:cmd, 'check': 0}
if a:0 > 0