File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change 1
- // SPDX-License-Identifier: BSD-3-Clause
2
1
// SPDX-FileCopyrightText: Copyright 2021 The Go Language Server Authors
2
+ // SPDX-License-Identifier: BSD-3-Clause
3
3
4
4
package protocol
5
5
6
6
import (
7
+ "bytes"
7
8
"context"
8
9
"fmt"
9
10
"io"
10
- "strings"
11
11
"sync"
12
12
"time"
13
13
@@ -106,7 +106,6 @@ func (s *loggingStream) logCommon(msg jsonrpc2.Message, isRead bool) {
106
106
}
107
107
108
108
s .logMu .Lock ()
109
- defer s .logMu .Unlock ()
110
109
111
110
direction , pastTense := "Received" , "Received"
112
111
get , set := maps .client , maps .setServer
@@ -118,7 +117,7 @@ func (s *loggingStream) logCommon(msg jsonrpc2.Message, isRead bool) {
118
117
tm := time .Now ()
119
118
tmfmt := tm .Format ("15:04:05.000 PM" )
120
119
121
- var buf strings. Builder
120
+ var buf bytes. Buffer
122
121
fmt .Fprintf (& buf , "[Trace - %s] " , tmfmt ) // common beginning
123
122
124
123
switch msg := msg .(type ) {
@@ -145,5 +144,7 @@ func (s *loggingStream) logCommon(msg jsonrpc2.Message, isRead bool) {
145
144
fmt .Fprintf (& buf , "Result: %s%s" , msg .Result (), eor )
146
145
}
147
146
148
- s .log .Write ([]byte (buf .String ()))
147
+ s .log .Write (buf .Bytes ())
148
+
149
+ s .logMu .Unlock ()
149
150
}
You can’t perform that action at this time.
0 commit comments