@@ -11,40 +11,41 @@ import (
11
11
12
12
type LSPLogger struct {
13
13
IncomingPrefix , OutgoingPrefix string
14
+ HiColor , LoColor func (format string , a ... interface {}) string
14
15
}
15
16
16
17
func (l * LSPLogger ) LogOutgoingRequest (id string , method string , params json.RawMessage ) {
17
- log .Print (color . HiGreenString ("%s REQU %s %s" , l .OutgoingPrefix , method , id ))
18
+ log .Print (l . HiColor ("%s REQU %s %s" , l .OutgoingPrefix , method , id ))
18
19
}
19
20
func (l * LSPLogger ) LogOutgoingCancelRequest (id string ) {
20
- log .Print (color . GreenString ("%s CANCEL %s" , l .OutgoingPrefix , id ))
21
+ log .Print (l . LoColor ("%s CANCEL %s" , l .OutgoingPrefix , id ))
21
22
}
22
23
func (l * LSPLogger ) LogIncomingResponse (id string , method string , resp json.RawMessage , respErr * jsonrpc.ResponseError ) {
23
- log .Print (color . GreenString ("%s RESP %s %s" , l .IncomingPrefix , method , id ))
24
+ log .Print (l . LoColor ("%s RESP %s %s" , l .IncomingPrefix , method , id ))
24
25
}
25
26
func (l * LSPLogger ) LogOutgoingNotification (method string , params json.RawMessage ) {
26
- log .Print (color . HiGreenString ("%s NOTIF %s" , l .OutgoingPrefix , method ))
27
+ log .Print (l . HiColor ("%s NOTIF %s" , l .OutgoingPrefix , method ))
27
28
}
28
29
29
30
func (l * LSPLogger ) LogIncomingRequest (id string , method string , params json.RawMessage ) jsonrpc.FunctionLogger {
30
31
spaces := " "
31
- log .Print (color . HiRedString (fmt .Sprintf ("%s REQU %s %s" , l .IncomingPrefix , method , id )))
32
+ log .Print (l . HiColor (fmt .Sprintf ("%s REQU %s %s" , l .IncomingPrefix , method , id )))
32
33
return & LSPFunctionLogger {
33
- colorFunc : color . HiRedString ,
34
+ colorFunc : l . HiColor ,
34
35
prefix : fmt .Sprintf ("%s %s %s" , spaces [:len (l .IncomingPrefix )], method , id ),
35
36
}
36
37
}
37
38
func (l * LSPLogger ) LogIncomingCancelRequest (id string ) {
38
- log .Print (color . RedString ("%s CANCEL %s" , l .IncomingPrefix , id ))
39
+ log .Print (l . LoColor ("%s CANCEL %s" , l .IncomingPrefix , id ))
39
40
}
40
41
func (l * LSPLogger ) LogOutgoingResponse (id string , method string , resp json.RawMessage , respErr * jsonrpc.ResponseError ) {
41
- log .Print (color . RedString ("%s RESP %s %s" , l .OutgoingPrefix , method , id ))
42
+ log .Print (l . LoColor ("%s RESP %s %s" , l .OutgoingPrefix , method , id ))
42
43
}
43
44
func (l * LSPLogger ) LogIncomingNotification (method string , params json.RawMessage ) jsonrpc.FunctionLogger {
44
45
spaces := " "
45
- log .Print (color . HiRedString (fmt .Sprintf ("%s NOTIF %s" , l .IncomingPrefix , method )))
46
+ log .Print (l . HiColor (fmt .Sprintf ("%s NOTIF %s" , l .IncomingPrefix , method )))
46
47
return & LSPFunctionLogger {
47
- colorFunc : color . HiRedString ,
48
+ colorFunc : l . HiColor ,
48
49
prefix : fmt .Sprintf ("%s %s" , spaces [:len (l .IncomingPrefix )], method ),
49
50
}
50
51
}
0 commit comments