mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-09 12:03:48 -05:00
Add simple logging.
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,3 +1,5 @@
|
||||
/doc/tags
|
||||
/misc
|
||||
/test/*.actual
|
||||
gitgutter.log
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ function! gitgutter#process_buffer(bufnr, realtime)
|
||||
endif
|
||||
endif
|
||||
catch /diff failed/
|
||||
call gitgutter#debug#log('diff failed')
|
||||
call gitgutter#hunk#reset()
|
||||
endtry
|
||||
else
|
||||
@@ -34,6 +35,8 @@ endfunction
|
||||
|
||||
|
||||
function! gitgutter#handle_diff_job(job_id, data, event)
|
||||
call gitgutter#debug#log('job_id: '.a:job_id.', event: '.a:event)
|
||||
|
||||
if a:event == 'stdout'
|
||||
" a:data is a list
|
||||
call gitgutter#utility#job_output_received(a:job_id, 'stdout')
|
||||
@@ -56,6 +59,8 @@ endfunction
|
||||
|
||||
|
||||
function! gitgutter#handle_diff(diff)
|
||||
call gitgutter#debug#log(a:diff)
|
||||
|
||||
call setbufvar(gitgutter#utility#bufnr(), 'gitgutter_tracked', 1)
|
||||
|
||||
call gitgutter#hunk#set_hunks(gitgutter#diff#parse_diff(a:diff))
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -50,6 +50,7 @@ call s:set('g:gitgutter_diff_base', '')
|
||||
call s:set('g:gitgutter_map_keys', 1)
|
||||
call s:set('g:gitgutter_avoid_cmd_prompt_on_windows', 1)
|
||||
call s:set('g:gitgutter_async', 1)
|
||||
call s:set('g:gitgutter_log', 0)
|
||||
|
||||
call gitgutter#highlight#define_sign_column_highlight()
|
||||
call gitgutter#highlight#define_highlights()
|
||||
|
||||
Reference in New Issue
Block a user