Skip to content

Commit

Permalink
Merge pull request #99 from lwabish/master
Browse files Browse the repository at this point in the history
fix: logger content leakage
  • Loading branch information
royalrick authored Apr 23, 2023
2 parents 592ab14 + f6e2d15 commit 360648d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ func (l *logger) Info(ctx context.Context, msg string, data ...interface{}) {
}
}
}
l.info = l.info[:1]
}
}

Expand All @@ -114,6 +115,7 @@ func (l *logger) Warn(ctx context.Context, msg string, data ...interface{}) {
}
}
}
l.warn = l.warn[:1]
}
}

Expand All @@ -131,6 +133,7 @@ func (l *logger) Error(ctx context.Context, msg string, data ...interface{}) {
}
}
}
l.err = l.err[:1]
}
}

Expand Down
15 changes: 15 additions & 0 deletions logger/logger_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package logger

import (
"context"
"log"
"os"
"testing"
)

func TestLogger(t *testing.T) {
l := NewLogger(log.New(os.Stdout, "\r\n", log.LstdFlags), Info, true)
for i := 0; i < 4; i++ {
l.Info(context.Background(), "request url: %d", i)
}
}

0 comments on commit 360648d

Please sign in to comment.