mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-08 11:33:48 -05:00
Add timestamps to log. Log channel traffic.
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,5 +1,5 @@
|
|||||||
/doc/tags
|
/doc/tags
|
||||||
/misc
|
/misc
|
||||||
/test/*.actual
|
/test/*.actual
|
||||||
gitgutter.log
|
*.log
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
let s:log_file = expand('<sfile>:p:h:h:h').'/'.'gitgutter.log'
|
let s:plugin_dir = expand('<sfile>:p:h:h:h').'/'
|
||||||
|
let s:log_file = s:plugin_dir.'gitgutter.log'
|
||||||
|
let s:channel_log = s:plugin_dir.'channel.log'
|
||||||
|
let s:new_log_session = 1
|
||||||
|
|
||||||
|
|
||||||
function! gitgutter#debug#debug()
|
function! gitgutter#debug#debug()
|
||||||
" Open a scratch buffer
|
" Open a scratch buffer
|
||||||
@@ -75,16 +79,39 @@ endfunction
|
|||||||
" assumes optional args are calling function's optional args
|
" assumes optional args are calling function's optional args
|
||||||
function! gitgutter#debug#log(message, ...)
|
function! gitgutter#debug#log(message, ...)
|
||||||
if g:gitgutter_log
|
if g:gitgutter_log
|
||||||
|
if s:new_log_session && gitgutter#async#available()
|
||||||
|
call ch_logfile(s:channel_log, 'w')
|
||||||
|
endif
|
||||||
|
|
||||||
execute 'redir >> '.s:log_file
|
execute 'redir >> '.s:log_file
|
||||||
|
if s:new_log_session
|
||||||
|
let s:start = reltime()
|
||||||
|
silent echo "\n==== start log session ===="
|
||||||
|
endif
|
||||||
|
|
||||||
|
let elapsed = reltimestr(reltime(s:start)).' '
|
||||||
|
silent echo ''
|
||||||
" callers excluding this function
|
" callers excluding this function
|
||||||
silent echo "\n".expand('<sfile>')[:-22].':'
|
silent echo elapsed.expand('<sfile>')[:-22].':'
|
||||||
silent echo type(a:message) == 1 ? join(split(a:message, '\n'),"\n") : a:message
|
silent echo elapsed.s:format_for_log(a:message)
|
||||||
if a:0 && !empty(a:1)
|
if a:0 && !empty(a:1)
|
||||||
for msg in a:000
|
for msg in a:000
|
||||||
silent echo type(msg) == 1 ? join(split(msg, '\n'),"\n") : msg
|
silent echo elapsed.s:format_for_log(msg)
|
||||||
endfor
|
endfor
|
||||||
endif
|
endif
|
||||||
redir END
|
redir END
|
||||||
|
|
||||||
|
let s:new_log_session = 0
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:format_for_log(data)
|
||||||
|
if type(a:data) == 1
|
||||||
|
return join(split(a:data,'\n'),"\n")
|
||||||
|
elseif type(a:data) == 3
|
||||||
|
return '['.join(a:data,"\n").']'
|
||||||
|
else
|
||||||
|
return a:data
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user