1
0
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:
wsdjeg 2022-01-05 07:49:01 +08:00
parent e9099b6611
commit da2f51ecb9
2 changed files with 15 additions and 2 deletions

View File

@ -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

View File

@ -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