Skip to content

Commit

Permalink
update echo middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
vuduongtp committed Mar 14, 2023
1 parent ff604e6 commit a22742d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions echo_adapter.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package logadapter

import (
"bytes"
"encoding/json"
"io"
"strconv"
Expand Down Expand Up @@ -300,11 +301,14 @@ func NewEchoLoggerMiddleware() echo.MiddlewareFunc {
"error": errStr,
}

var buf bytes.Buffer
b, _ := json.Marshal(trace)
buf.Write(b)
buf.WriteString("\n")
if logger, ok := c.Logger().(*EchoLogAdapter); ok {
logger.Output().Write(b)
logger.Output().Write(buf.Bytes())
} else {
c.Logger().Output().Write(b)
c.Logger().Output().Write(buf.Bytes())
}

return err
Expand Down

0 comments on commit a22742d

Please sign in to comment.