Skip to content

Commit

Permalink
misc: use slog stack formatter
Browse files Browse the repository at this point in the history
Signed-off-by: He Xian <[email protected]>
  • Loading branch information
hexian000 committed Nov 29, 2024
1 parent b381dd1 commit 6798cd6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion v3/forwarder/forwarder.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (f *forwarder) delConn(accepted net.Conn, dialed net.Conn) {
func (f *forwarder) connCopy(dst net.Conn, src net.Conn) {
defer func() {
if err := recover(); err != nil {
slog.Error("panic: ", err)
slog.Stackf(slog.LevelError, 0, "panic: %v", err)
}
}()
_, err := io.Copy(dst, src)
Expand Down
3 changes: 1 addition & 2 deletions v3/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"fmt"
"io"
"net"
"runtime/debug"
"sync"
"sync/atomic"
"time"
Expand Down Expand Up @@ -153,7 +152,7 @@ func (s *Server) dialDirect(ctx context.Context, addr string) (net.Conn, error)
func (s *Server) serveOne(accepted net.Conn, handler Handler) {
defer func() {
if r := recover(); r != nil {
slog.Errorf("panic: %v\n%s", r, string(debug.Stack()))
slog.Stackf(slog.LevelError, 0, "panic: %v", r)
}
}()
ctx := s.ctx.withTimeout()
Expand Down

0 comments on commit 6798cd6

Please sign in to comment.