mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 17:40:06 +08:00
fix(logger): add reltimefloat compatible api
This commit is contained in:
parent
e9099b6611
commit
da2f51ecb9
@ -17,6 +17,8 @@
|
||||
" {silent} is a Boolean. by default it is false, and log will be print to
|
||||
" screen.
|
||||
|
||||
let s:TIME = SpaceVim#api#import('time')
|
||||
|
||||
let s:self = {
|
||||
\ 'name' : '',
|
||||
\ 'silent' : 1,
|
||||
@ -55,7 +57,7 @@ function! s:self._build_msg(msg, l) abort
|
||||
let log = printf('[ %s ] [%s] [%00.3f] [ %5s ] %s',
|
||||
\ self.name,
|
||||
\ time,
|
||||
\ reltimefloat(reltime(self.clock)),
|
||||
\ s:TIME.reltimefloat(reltime(self.clock)),
|
||||
\ self.levels[a:l],
|
||||
\ msg)
|
||||
return log
|
||||
|
@ -31,7 +31,18 @@ function! s:self.current_date() abort
|
||||
return strftime('%a %b %d')
|
||||
endfunction
|
||||
|
||||
" reltimefloat() is added in 7.4.1724
|
||||
if exists('*reltimefloat')
|
||||
function! s:self.reltimefloat(reltime) abort
|
||||
return reltimefloat(a:reltime)
|
||||
endfunction
|
||||
else
|
||||
function! s:self.reltimefloat(reltime) abort
|
||||
return str2float(reltimestr(a:reltime))
|
||||
endfunction
|
||||
endif
|
||||
|
||||
|
||||
function! SpaceVim#api#time#get() abort
|
||||
return deepcopy(s:self)
|
||||
return deepcopy(s:self)
|
||||
endfunction
|
||||
|
Loading…
Reference in New Issue
Block a user