Skip to content

Added logging of LSP calls duration and increased resolution of timestamps #110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -9,6 +9,6 @@ require (
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.7.0
go.bug.st/json v1.15.6
go.bug.st/lsp v0.0.0-20211202163946-3ad3994172a0
go.bug.st/lsp v0.0.0-20220608135618-8a2f8eb9ad1b
google.golang.org/grpc v1.42.0
)
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -337,10 +337,8 @@ go.bug.st/downloader/v2 v2.1.1 h1:nyqbUizo3E2IxCCm4YFac4FtSqqFpqWP+Aae5GCMuw4=
go.bug.st/downloader/v2 v2.1.1/go.mod h1:VZW2V1iGKV8rJL2ZEGIDzzBeKowYv34AedJz13RzVII=
go.bug.st/json v1.15.6 h1:pvSpotu6f5JoCbx1TnKn6asVH7o9Tg2/GKsZSVzBOsc=
go.bug.st/json v1.15.6/go.mod h1:bh58F9adz5ePlNqtvbuXuXcf9k6IrDLKH6lJUsHP3TI=
go.bug.st/lsp v0.0.0-20211130152916-c597b0a0439f h1:Rj7FdBdROWh9mMra/16G/5d7u/QE0Wwq487NZt+Evjg=
go.bug.st/lsp v0.0.0-20211130152916-c597b0a0439f/go.mod h1:oYTh1uf5hI1teV5crrWut41Pk8vD/NqIjs4zD+No5FE=
go.bug.st/lsp v0.0.0-20211202163946-3ad3994172a0 h1:/SnZ7aZ3bmfUKWbhckiK6L4mv9vyf9HgwV6X0dm+/is=
go.bug.st/lsp v0.0.0-20211202163946-3ad3994172a0/go.mod h1:oYTh1uf5hI1teV5crrWut41Pk8vD/NqIjs4zD+No5FE=
go.bug.st/lsp v0.0.0-20220608135618-8a2f8eb9ad1b h1:JkRunYlYDXFIgMf3BfgFrQyvHCsqkUuCGL9CUYhY3zc=
go.bug.st/lsp v0.0.0-20220608135618-8a2f8eb9ad1b/go.mod h1:oYTh1uf5hI1teV5crrWut41Pk8vD/NqIjs4zD+No5FE=
go.bug.st/relaxed-semver v0.0.0-20190922224835-391e10178d18 h1:F1qxtaFuewctYc/SsHRn+Q7Dtwi+yJGPgVq8YLtQz98=
go.bug.st/relaxed-semver v0.0.0-20190922224835-391e10178d18/go.mod h1:Cx1VqMtEhE9pIkEyUj3LVVVPkv89dgW8aCKrRPDR/uE=
go.bug.st/serial v1.3.2/go.mod h1:jDkjqASf/qSjmaOxHSHljwUQ6eHo/ZX/bxJLQqSlvZg=
11 changes: 11 additions & 0 deletions ls/lsp_logger.go
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ package ls
import (
"fmt"
"log"
"time"

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

func init() {
log.SetFlags(log.Lmicroseconds)
}

func (l *LSPLogger) LogOutgoingRequest(id string, method string, params json.RawMessage) {
log.Print(l.HiColor("%s REQU %s %s", l.OutgoingPrefix, method, id))
}
@@ -58,6 +63,12 @@ func (l *LSPLogger) LogIncomingNotification(method string, params json.RawMessag
prefix: fmt.Sprintf("%s %s", spaces[:len(l.IncomingPrefix)], method),
}
}
func (l *LSPLogger) LogIncomingDataDelay(delay time.Duration) {
log.Printf("IN Elapsed: %v", delay)
}
func (l *LSPLogger) LogOutgoingDataDelay(delay time.Duration) {
log.Printf("OUT Elapsed: %v", delay)
}

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