forked from Exafunction/windsurf.vim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlog.vim
More file actions
60 lines (51 loc) · 1.42 KB
/
log.vim
File metadata and controls
60 lines (51 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
if exists('g:loaded_codeium_log')
finish
endif
let g:loaded_codeium_log = 1
if !exists('s:logfile')
let s:logfile = expand(get(g:, 'codeium_log_file', tempname() . '-codeium.log'))
try
call writefile([], s:logfile)
catch
endtry
endif
function! codeium#log#Logfile() abort
return s:logfile
endfunction
function! codeium#log#Log(level, msg) abort
let min_level = toupper(get(g:, 'codeium_log_level', 'WARN'))
" echo "logging to: " . s:logfile . "," . min_level . "," . a:level . "," a:msg
for level in ['ERROR', 'WARN', 'INFO', 'DEBUG', 'TRACE']
if level == toupper(a:level)
try
if filewritable(s:logfile)
call writefile(split(a:msg, "\n", 1), s:logfile, 'a')
endif
catch
endtry
endif
if level == min_level
break
endif
endfor
endfunction
function! codeium#log#Error(msg) abort
call codeium#log#Log('ERROR', a:msg)
endfunction
function! codeium#log#Warn(msg) abort
call codeium#log#Log('WARN', a:msg)
endfunction
function! codeium#log#Info(msg) abort
call codeium#log#Log('INFO', a:msg)
endfunction
function! codeium#log#Debug(msg) abort
call codeium#log#Log('DEBUG', a:msg)
endfunction
function! codeium#log#Trace(msg) abort
call codeium#log#Log('TRACE', a:msg)
endfunction
function! codeium#log#Exception() abort
if !empty(v:exception)
call codeium#log#Error('Exception: ' . v:exception . ' [' . v:throwpoint . ']')
endif
endfunction