mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-09 09:40:04 +08:00
Add logger
This commit is contained in:
parent
cc9a7796aa
commit
c046df4956
1
.gitignore
vendored
1
.gitignore
vendored
@ -8,3 +8,4 @@ doc/tags
|
|||||||
*-rplugin~
|
*-rplugin~
|
||||||
*rplugin.vim
|
*rplugin.vim
|
||||||
/config/local.vim
|
/config/local.vim
|
||||||
|
.SpaceVim.log
|
||||||
|
@ -84,6 +84,13 @@ let g:spacevim_plugin_manager = 'dein' " neobundle or dein or vim-plug
|
|||||||
" let g:spacevim_checkinstall = 0
|
" let g:spacevim_checkinstall = 0
|
||||||
" <
|
" <
|
||||||
let g:spacevim_checkinstall = 1
|
let g:spacevim_checkinstall = 1
|
||||||
|
""
|
||||||
|
" Enable/Disable debug mode for SpaceVim, by default it is disabled.
|
||||||
|
"
|
||||||
|
" to enable it: >
|
||||||
|
" let g:spacevim_enable_debug = 1
|
||||||
|
" <
|
||||||
|
let g:spacevim_enable_debug = 0
|
||||||
let g:spacevim_hiddenfileinfo = 1
|
let g:spacevim_hiddenfileinfo = 1
|
||||||
let g:spacevim_plugin_groups_exclude = []
|
let g:spacevim_plugin_groups_exclude = []
|
||||||
""
|
""
|
||||||
|
53
autoload/SpaceVim/logger.vim
Normal file
53
autoload/SpaceVim/logger.vim
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
let s:logger_level = 0
|
||||||
|
let s:levels = ['Info', 'Warn', 'Error']
|
||||||
|
let s:logger_file = expand('~/.SpaceVim/.SpaceVim.log')
|
||||||
|
""
|
||||||
|
" @public
|
||||||
|
" Set debug level of SpaceVim, by default it is 0.
|
||||||
|
"
|
||||||
|
" 0 : log all the message.
|
||||||
|
"
|
||||||
|
" 1 : log warning and error message
|
||||||
|
"
|
||||||
|
" 2 : log error message only
|
||||||
|
function! SpaceVim#logger#setLevel(level) abort
|
||||||
|
let s:logger_level = a:level
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:wite(msg) abort
|
||||||
|
call writefile([a:msg], s:logger_file, 'a')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! SpaceVim#logger#info(msg) abort
|
||||||
|
call s:wite(s:warpMsg(a:msg, 1))
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! SpaceVim#logger#viewLog(...) abort
|
||||||
|
let l = a:0 > 0 ? a:1 : 0
|
||||||
|
let logs = readfile(s:logger_file, '')
|
||||||
|
for log in logs
|
||||||
|
if log =~# '\[ SpaceVim \] \[\d\d\:\d\d\:\d\d\] \[' . s:levels[l] .'\]'
|
||||||
|
echo log
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
""
|
||||||
|
" @public
|
||||||
|
" Set log output file of SpaceVim. by default it is
|
||||||
|
" `~/.SpaceVim/.SpaceVim.log`
|
||||||
|
function! SpaceVim#logger#setOutput(file) abort
|
||||||
|
let s:logger_file = a:file
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:warpMsg(msg,l) abort
|
||||||
|
let time = strftime('%H:%M:%S')
|
||||||
|
let log = '[ SpaceVim ] [' . time . '] [' . s:levels[a:l - 1] . '] ' . a:msg
|
||||||
|
return log
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! SpaceVim#logger#echoWarn(msg) abort
|
||||||
|
echohl WarningMsg
|
||||||
|
echom s:warpMsg(a:msg, 1)
|
||||||
|
echohl None
|
||||||
|
endfunction
|
@ -82,6 +82,14 @@ To disable it:
|
|||||||
let g:spacevim_checkinstall = 0
|
let g:spacevim_checkinstall = 0
|
||||||
<
|
<
|
||||||
|
|
||||||
|
*g:spacevim_enable_debug*
|
||||||
|
Enable/Disable debug mode for SpaceVim, by default it is disabled.
|
||||||
|
|
||||||
|
to enable it:
|
||||||
|
>
|
||||||
|
let g:spacevim_enable_debug = 1
|
||||||
|
<
|
||||||
|
|
||||||
*g:spacevim_plugin_groups*
|
*g:spacevim_plugin_groups*
|
||||||
groups of plugins should be loaded.
|
groups of plugins should be loaded.
|
||||||
|
|
||||||
@ -119,5 +127,18 @@ SpaceVim#Layer({layer}) *SpaceVim#Layer()*
|
|||||||
Load the {layer} you want : autocompletion : Make SpaceVim support
|
Load the {layer} you want : autocompletion : Make SpaceVim support
|
||||||
autocompletion. unite : Unite centric work-flow
|
autocompletion. unite : Unite centric work-flow
|
||||||
|
|
||||||
|
SpaceVim#logger#setLevel({level}) *SpaceVim#logger#setLevel()*
|
||||||
|
Set debug level of SpaceVim, by default it is 0.
|
||||||
|
|
||||||
|
0 : log all the message.
|
||||||
|
|
||||||
|
1 : log warning and error message
|
||||||
|
|
||||||
|
2 : log error message only
|
||||||
|
|
||||||
|
SpaceVim#logger#setOutput({file}) *SpaceVim#logger#setOutput()*
|
||||||
|
Set log output file of SpaceVim. by default it is
|
||||||
|
`~/.SpaceVim/.SpaceVim.log`
|
||||||
|
|
||||||
|
|
||||||
vim:tw=78:ts=8:ft=help:norl:
|
vim:tw=78:ts=8:ft=help:norl:
|
||||||
|
Loading…
Reference in New Issue
Block a user