mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-08 19:43:47 -05:00
Add simple logging.
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,3 +1,5 @@
|
|||||||
/doc/tags
|
/doc/tags
|
||||||
/misc
|
/misc
|
||||||
/test/*.actual
|
/test/*.actual
|
||||||
|
gitgutter.log
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ function! gitgutter#process_buffer(bufnr, realtime)
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
catch /diff failed/
|
catch /diff failed/
|
||||||
|
call gitgutter#debug#log('diff failed')
|
||||||
call gitgutter#hunk#reset()
|
call gitgutter#hunk#reset()
|
||||||
endtry
|
endtry
|
||||||
else
|
else
|
||||||
@@ -34,6 +35,8 @@ endfunction
|
|||||||
|
|
||||||
|
|
||||||
function! gitgutter#handle_diff_job(job_id, data, event)
|
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'
|
if a:event == 'stdout'
|
||||||
" a:data is a list
|
" a:data is a list
|
||||||
call gitgutter#utility#job_output_received(a:job_id, 'stdout')
|
call gitgutter#utility#job_output_received(a:job_id, 'stdout')
|
||||||
@@ -56,6 +59,8 @@ endfunction
|
|||||||
|
|
||||||
|
|
||||||
function! gitgutter#handle_diff(diff)
|
function! gitgutter#handle_diff(diff)
|
||||||
|
call gitgutter#debug#log(a:diff)
|
||||||
|
|
||||||
call setbufvar(gitgutter#utility#bufnr(), 'gitgutter_tracked', 1)
|
call setbufvar(gitgutter#utility#bufnr(), 'gitgutter_tracked', 1)
|
||||||
|
|
||||||
call gitgutter#hunk#set_hunks(gitgutter#diff#parse_diff(a:diff))
|
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()
|
function! gitgutter#debug#debug()
|
||||||
" Open a scratch buffer
|
" Open a scratch buffer
|
||||||
vsplit __GitGutter_Debug__
|
vsplit __GitGutter_Debug__
|
||||||
@@ -70,8 +72,19 @@ function! gitgutter#debug#output(text)
|
|||||||
call append(line('$'), a:text)
|
call append(line('$'), a:text)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! gitgutter#debug#log(message)
|
" assumes optional args are calling function's optional args
|
||||||
let msg = type(a:message) == 1 ? split(a:message, '\n') : a:message
|
function! gitgutter#debug#log(message, ...)
|
||||||
call writefile(msg, 'gitgutter.log', 'a')
|
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
|
endfunction
|
||||||
|
|
||||||
|
|||||||
@@ -134,9 +134,11 @@ function! gitgutter#diff#run_diff(realtime, preserve_full_diff)
|
|||||||
\ 'on_stderr': function('gitgutter#handle_diff_job'),
|
\ 'on_stderr': function('gitgutter#handle_diff_job'),
|
||||||
\ 'on_exit': 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
|
if job_id < 1
|
||||||
throw 'diff failed'
|
throw 'diff failed'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call gitgutter#utility#pending_job(job_id)
|
call gitgutter#utility#pending_job(job_id)
|
||||||
return 'async'
|
return 'async'
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -121,6 +121,8 @@ function! gitgutter#utility#using_xolox_shell()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! gitgutter#utility#system(cmd, ...)
|
function! gitgutter#utility#system(cmd, ...)
|
||||||
|
call gitgutter#debug#log(a:cmd, a:000)
|
||||||
|
|
||||||
if gitgutter#utility#using_xolox_shell()
|
if gitgutter#utility#using_xolox_shell()
|
||||||
let options = {'command': a:cmd, 'check': 0}
|
let options = {'command': a:cmd, 'check': 0}
|
||||||
if a:0 > 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_map_keys', 1)
|
||||||
call s:set('g:gitgutter_avoid_cmd_prompt_on_windows', 1)
|
call s:set('g:gitgutter_avoid_cmd_prompt_on_windows', 1)
|
||||||
call s:set('g:gitgutter_async', 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_sign_column_highlight()
|
||||||
call gitgutter#highlight#define_highlights()
|
call gitgutter#highlight#define_highlights()
|
||||||
|
|||||||
Reference in New Issue
Block a user