Skip to content

Commit

Permalink
Added some locks and checks
Browse files Browse the repository at this point in the history
Signed-off-by: Yash Sharma <[email protected]>
  • Loading branch information
yashrsharma44 committed Oct 9, 2020
1 parent 2b54459 commit 1b1a25d
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions interceptors/logging/interceptors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ func (l LogLines) Less(i, j int) bool {
if l[i].msg != l[j].msg {
return l[i].msg < l[j].msg
}
//_ , aok = l[i].fields["grpc.response.content"]
//_ ,baok = l[i].fields["grpc.response.content"]
//if

// We want to sort by counter which in string, so we need to parse it.
a := testpb.PingResponse{}
Expand All @@ -94,13 +91,6 @@ type baseMockLogger struct {
m sync.Mutex
}

func (l *baseMockLogger) Add(line LogLine) {
l.m.Lock()
defer l.m.Unlock()

l.lines = append(l.lines, line)
}

func (l *baseMockLogger) Lines() []LogLine {
l.m.Lock()
defer l.m.Unlock()
Expand All @@ -126,14 +116,12 @@ func (l *mockLogger) Log(lvl logging.Level, msg string) {
for i := 0; i < len(l.fields); i += 2 {
line.fields[l.fields[i]] = l.fields[i+1]
}
l.Add(line)

l.lines = append(l.lines, line)
}

func (l *mockLogger) With(fields ...string) logging.Logger {
// Append twice to copy slice, so we don't reuse array.
l.m.Lock()
defer l.m.Unlock()

return &mockLogger{baseMockLogger: l.baseMockLogger, fields: append(append(logging.Fields{}, l.fields...), fields...)}
}

Expand Down

0 comments on commit 1b1a25d

Please sign in to comment.