1
0
mirror of https://github.com/fumiama/WireGold.git synced 2026-06-28 06:40:26 +08:00

optimize(gold): apply more buffer pools

This commit is contained in:
源文雨
2024-07-15 01:22:12 +09:00
parent 32af3ce142
commit 17e1f6cac9
8 changed files with 152 additions and 71 deletions

View File

@@ -169,8 +169,7 @@ type logFormat struct {
// Format implements logrus.Formatter
func (f logFormat) Format(entry *logrus.Entry) ([]byte, error) {
buf := helper.SelectWriter()
defer helper.PutWriter(buf)
buf := helper.SelectWriter() // this writer will not be put back
buf.WriteByte('[')
if f.enableColor {
@@ -184,9 +183,7 @@ func (f logFormat) Format(entry *logrus.Entry) ([]byte, error) {
buf.WriteString(entry.Message)
buf.WriteString("\n")
ret := make([]byte, len(buf.Bytes()))
copy(ret, buf.Bytes()) // copy buffer
return ret, nil
return buf.Bytes(), nil
}
const (