File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,13 @@ func SessionIdleErr(timeout time.Duration) error {
2424
2525type transportSender func (session * packet.Session ) error
2626
27+ // ErrVithVariableSeverity are errors that have variable severity
28+ type ErrVithVariableSeverity interface {
29+ error
30+ // LogLevel return the severity of this error
31+ LogLevel () zerolog.Level
32+ }
33+
2734// Session is a bidirectional pipe of datagrams between transport and dstConn
2835// Destination can be a connection with origin or with eyeball
2936// When the destination is origin:
@@ -53,7 +60,11 @@ func (s *Session) Serve(ctx context.Context, closeAfterIdle time.Duration) (clos
5360 if errors .Is (err , net .ErrClosed ) {
5461 s .log .Debug ().Msg ("Destination connection closed" )
5562 } else {
56- s .log .Error ().Err (err ).Msg ("Failed to send session payload from destination to transport" )
63+ level := zerolog .ErrorLevel
64+ if variableErr , ok := err .(ErrVithVariableSeverity ); ok {
65+ level = variableErr .LogLevel ()
66+ }
67+ s .log .WithLevel (level ).Err (err ).Msg ("Failed to send session payload from destination to transport" )
5768 }
5869 if closeSession {
5970 s .closeChan <- err
You can’t perform that action at this time.
0 commit comments