mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 22:30:04 +08:00
Update logger api
This commit is contained in:
parent
9c6c99f639
commit
702504768b
@ -471,11 +471,11 @@ function! SpaceVim#loadCustomConfig() abort
|
||||
endif
|
||||
" the old value will be remove
|
||||
if filereadable(custom_glob_conf_old)
|
||||
SpaceVim#logger#warn('~/.local.vim is deprecated!')
|
||||
call SpaceVim#logger#warn('~/.local.vim is deprecated!')
|
||||
exe 'source ' . custom_glob_conf_old
|
||||
endif
|
||||
if !empty(custom_confs_old)
|
||||
SpaceVim#logger#warn('.local.vim is deprecated!')
|
||||
call SpaceVim#logger#warn('.local.vim is deprecated!')
|
||||
exe 'source ' . custom_confs_old[0]
|
||||
endif
|
||||
|
||||
|
@ -3,6 +3,7 @@ let s:self = {
|
||||
\ 'name' : '',
|
||||
\ 'silent' : 1,
|
||||
\ 'level' : 1,
|
||||
\ 'verbose' : 1,
|
||||
\ 'file' : '',
|
||||
\ 'temp' : [],
|
||||
\ }
|
||||
@ -16,6 +17,14 @@ function! SpaceVim#api#logger#get() abort
|
||||
return deepcopy(s:self)
|
||||
endfunction
|
||||
|
||||
function! s:self.set_silent(sl) abort
|
||||
let self.silent = a:sl
|
||||
endfunction
|
||||
|
||||
function! s:self.set_verbose(vb) abort
|
||||
let self.verbose = a:vb
|
||||
endfunction
|
||||
|
||||
function! s:self.set_level(l) abort
|
||||
let self.level = a:l
|
||||
endfunction
|
||||
@ -23,8 +32,10 @@ endfunction
|
||||
function! s:self.error(msg) abort
|
||||
let time = strftime('%H:%M:%S')
|
||||
let log = '[ ' . self.name . ' ] [' . time . '] [ ' . s:levels[2] . ' ] ' . a:msg
|
||||
if !self.silent
|
||||
echoerr log
|
||||
if !self.silent && self.verbose >= 1
|
||||
echohl Error
|
||||
echom log
|
||||
echohl None
|
||||
endif
|
||||
call self.write(log)
|
||||
endfunction
|
||||
@ -47,7 +58,7 @@ function! s:self.warn(msg) abort
|
||||
endif
|
||||
let time = strftime('%H:%M:%S')
|
||||
let log = '[ ' . self.name . ' ] [' . time . '] [ ' . s:levels[1] . ' ] ' . a:msg
|
||||
if !self.silent
|
||||
if !self.silent && self.verbose >= 2
|
||||
echohl WarningMsg
|
||||
echom log
|
||||
echohl None
|
||||
@ -61,7 +72,7 @@ function! s:self.info(msg) abort
|
||||
endif
|
||||
let time = strftime('%H:%M:%S')
|
||||
let log = '[ ' . self.name . ' ] [' . time . '] [ ' . s:levels[0] . ' ] ' . a:msg
|
||||
if !self.silent
|
||||
if !self.silent && self.verbose >= 3
|
||||
echom log
|
||||
endif
|
||||
call self.write(log)
|
||||
|
@ -2,6 +2,8 @@ let s:LOGGER = SpaceVim#api#import('logger')
|
||||
|
||||
call s:LOGGER.set_name('SpaceVim')
|
||||
call s:LOGGER.set_level(1)
|
||||
call s:LOGGER.set_silent(0)
|
||||
call s:LOGGER.set_verbose(2)
|
||||
|
||||
function! SpaceVim#logger#info(msg)
|
||||
|
||||
@ -9,7 +11,6 @@ function! SpaceVim#logger#info(msg)
|
||||
|
||||
endfunction
|
||||
|
||||
|
||||
function! SpaceVim#logger#warn(msg)
|
||||
|
||||
call s:LOGGER.warn(a:msg)
|
||||
|
@ -100,9 +100,7 @@ function! s:need_cmd(cmd) abort
|
||||
if executable(a:cmd)
|
||||
return 1
|
||||
else
|
||||
echohl WarningMsg
|
||||
echom '[SpaceVim] [plugin manager] You need install ' . a:cmd . '!'
|
||||
echohl None
|
||||
call SpaceVim#logger#warn(' [ plug manager ] need command: ' . a:cmd)
|
||||
return 0
|
||||
endif
|
||||
endfunction
|
||||
@ -124,16 +122,12 @@ function! SpaceVim#plugins#manager#install(...) abort
|
||||
endif
|
||||
let s:plugins = a:0 == 0 ? sort(map(s:get_uninstalled_plugins(), 'v:val.name')) : sort(copy(a:1))
|
||||
if empty(s:plugins)
|
||||
echohl WarningMsg
|
||||
echom '[SpaceVim] Wrong plugin name, or all of the plugins are already installed.'
|
||||
echohl None
|
||||
call SpaceVim#logger#warn(' [ plug manager ] Wrong plugin name, or all of the plugins are already installed.')
|
||||
return
|
||||
endif
|
||||
let status = s:new_window()
|
||||
if status == 0
|
||||
echohl WarningMsg
|
||||
echom '[SpaceVim] [plugin manager] plugin manager process is not finished.'
|
||||
echohl None
|
||||
call SpaceVim#logger#warn(' [ plug manager ] plugin manager process is not finished.')
|
||||
return
|
||||
elseif status == 1
|
||||
" resume window
|
||||
|
Loading…
Reference in New Issue
Block a user