fix logs not printing correctly, removed unneccessary loggers

This commit is contained in:
yusing
2025-01-20 17:42:54 +08:00
parent 64e85c3076
commit dd0bbdc7b4
38 changed files with 130 additions and 150 deletions

View File

@@ -119,7 +119,7 @@ func ConnectClient(host string) (*SharedClient, error) {
Client: client,
key: host,
refCount: U.NewRefCounter(),
l: logger.With().Str("address", client.DaemonHost()).Logger(),
l: logging.With().Str("address", client.DaemonHost()).Logger(),
}
c.l.Trace().Msg("client connected")

View File

@@ -6,6 +6,7 @@ import (
"strings"
"github.com/docker/docker/api/types"
"github.com/yusing/go-proxy/internal/logging"
U "github.com/yusing/go-proxy/internal/utils"
"github.com/yusing/go-proxy/internal/utils/strutils"
)
@@ -128,7 +129,7 @@ func (c *Container) setPublicIP() {
}
url, err := url.Parse(c.DockerHost)
if err != nil {
logger.Err(err).Msgf("invalid docker host %q, falling back to 127.0.0.1", c.DockerHost)
logging.Err(err).Msgf("invalid docker host %q, falling back to 127.0.0.1", c.DockerHost)
c.PublicIP = "127.0.0.1"
return
}

View File

@@ -46,8 +46,6 @@ var (
watcherMapMu sync.Mutex
errShouldNotReachHere = errors.New("should not reach here")
logger = logging.With().Str("module", "idle_watcher").Logger()
)
const dockerReqTimeout = 3 * time.Second
@@ -78,7 +76,7 @@ func registerWatcher(watcherTask *task.Task, entry route.Entry, waker *waker) (*
}
w := &Watcher{
Logger: logger.With().Str("name", cfg.ContainerName).Logger(),
Logger: logging.With().Str("name", cfg.ContainerName).Logger(),
Config: cfg,
waker: waker,
client: client,

View File

@@ -1,7 +0,0 @@
package docker
import (
"github.com/yusing/go-proxy/internal/logging"
)
var logger = logging.With().Str("module", "docker").Logger()