Skip to content

Commit 1b571c4

Browse files
committed
Added logging of timings
1 parent 835a2f5 commit 1b571c4

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ require (
99
github.com/pkg/errors v0.9.1
1010
github.com/stretchr/testify v1.7.0
1111
go.bug.st/json v1.15.6
12-
go.bug.st/lsp v0.0.0-20211202163946-3ad3994172a0
12+
go.bug.st/lsp v0.0.0-20220608135618-8a2f8eb9ad1b
1313
google.golang.org/grpc v1.42.0
1414
)

ls/lsp_logger.go

+11
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package ls
33
import (
44
"fmt"
55
"log"
6+
"time"
67

78
"github.com/fatih/color"
89
"go.bug.st/json"
@@ -15,6 +16,10 @@ type LSPLogger struct {
1516
ErrorColor func(format string, a ...interface{}) string
1617
}
1718

19+
func init() {
20+
log.SetFlags(log.Lmicroseconds)
21+
}
22+
1823
func (l *LSPLogger) LogOutgoingRequest(id string, method string, params json.RawMessage) {
1924
log.Print(l.HiColor("%s REQU %s %s", l.OutgoingPrefix, method, id))
2025
}
@@ -58,6 +63,12 @@ func (l *LSPLogger) LogIncomingNotification(method string, params json.RawMessag
5863
prefix: fmt.Sprintf("%s %s", spaces[:len(l.IncomingPrefix)], method),
5964
}
6065
}
66+
func (l *LSPLogger) LogIncomingDataDelay(delay time.Duration) {
67+
log.Printf("IN Elapsed: %v", delay)
68+
}
69+
func (l *LSPLogger) LogOutgoingDataDelay(delay time.Duration) {
70+
log.Printf("OUT Elapsed: %v", delay)
71+
}
6172

6273
type LSPFunctionLogger struct {
6374
colorFunc func(format string, a ...interface{}) string

0 commit comments

Comments
 (0)