refactor: simplify io code and make utils module independent

This commit is contained in:
yusing
2025-05-23 22:19:14 +08:00
parent ff08c40403
commit f1e204f7fd
24 changed files with 124 additions and 73 deletions

View File

@@ -4,7 +4,7 @@ import (
"time"
"github.com/yusing/go-proxy/internal/gperr"
"github.com/yusing/go-proxy/internal/utils"
"github.com/yusing/go-proxy/internal/serialization"
)
type (
@@ -126,6 +126,6 @@ func DefaultACLLoggerConfig() *ACLLoggerConfig {
}
func init() {
utils.RegisterDefaultValueFactory(DefaultRequestLoggerConfig)
utils.RegisterDefaultValueFactory(DefaultACLLoggerConfig)
serialization.RegisterDefaultValueFactory(DefaultRequestLoggerConfig)
serialization.RegisterDefaultValueFactory(DefaultACLLoggerConfig)
}

View File

@@ -10,6 +10,8 @@ import (
"github.com/rs/zerolog"
"github.com/yusing/go-proxy/internal/common"
"github.com/yusing/go-proxy/internal/utils/strutils"
zerologlog "github.com/rs/zerolog/log"
)
var (
@@ -61,6 +63,8 @@ func InitLogger(out ...io.Writer) {
log.SetOutput(writer)
log.SetPrefix("")
log.SetFlags(0)
zerolog.TimeFieldFormat = timeFmt
zerologlog.Logger = logger
}
func DiscardLogger() { zerolog.SetGlobalLevel(zerolog.Disabled) }