sing-box/experimental/deprecated/stderr.go

39 lines
876 B
Go
Raw Permalink Normal View History

2024-10-18 01:58:03 +00:00
package deprecated
import (
"os"
"strconv"
"github.com/sagernet/sing/common/logger"
)
2024-11-07 11:58:46 +00:00
type stderrManager struct {
logger logger.Logger
reported map[string]bool
2024-10-18 01:58:03 +00:00
}
2024-11-07 11:58:46 +00:00
func NewStderrManager(logger logger.Logger) Manager {
return &stderrManager{
logger: logger,
reported: make(map[string]bool),
}
2024-10-18 01:58:03 +00:00
}
2024-11-07 11:58:46 +00:00
func (f *stderrManager) ReportDeprecated(feature Note) {
if f.reported[feature.Name] {
return
}
f.reported[feature.Name] = true
2024-10-18 01:58:03 +00:00
if !feature.Impending() {
f.logger.Warn(feature.MessageWithLink())
return
}
enable, enableErr := strconv.ParseBool(os.Getenv("ENABLE_DEPRECATED_" + feature.EnvName))
if enableErr == nil && enable {
f.logger.Warn(feature.MessageWithLink())
return
}
f.logger.Error(feature.MessageWithLink())
2024-11-22 09:17:01 +00:00
f.logger.Fatal("to continuing using this feature, set environment variable ENABLE_DEPRECATED_" + feature.EnvName + "=true")
2024-10-18 01:58:03 +00:00
}