Fix write log to stderr

This commit is contained in:
世界 2023-04-10 08:48:58 +08:00
parent aceb82a75e
commit da82a41697
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
3 changed files with 6 additions and 3 deletions

View file

@ -63,7 +63,7 @@ func (s *CommandServer) handleLogConn(conn net.Conn) error {
for {
select {
case <-ctx.Done():
return nil
return ctx.Err()
case message := <-subscription:
err = writeLog(conn, []byte(message))
if err != nil {

View file

@ -9,6 +9,7 @@ import (
"github.com/sagernet/sing-box/log"
"github.com/sagernet/sing/common"
"github.com/sagernet/sing/common/debug"
E "github.com/sagernet/sing/common/exceptions"
"github.com/sagernet/sing/common/observable"
"github.com/sagernet/sing/common/x/list"
@ -71,7 +72,9 @@ func (s *CommandServer) loopConnection(listener net.Listener) {
go func() {
hErr := s.handleConnection(conn)
if hErr != nil && !E.IsClosed(err) {
log.Warn("log-server: process connection: ", hErr)
if debug.Enabled {
log.Warn("log-server: process connection: ", hErr)
}
}
}()
}

View file

@ -42,7 +42,7 @@ func (s *CommandServer) handleStatusConn(conn net.Conn) error {
}
select {
case <-ctx.Done():
return nil
return ctx.Err()
case <-ticker.C:
}
}