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

@@ -9,6 +9,7 @@ import (
"github.com/fsnotify/fsnotify"
"github.com/rs/zerolog"
E "github.com/yusing/go-proxy/internal/error"
"github.com/yusing/go-proxy/internal/logging"
"github.com/yusing/go-proxy/internal/task"
"github.com/yusing/go-proxy/internal/watcher/events"
)
@@ -40,13 +41,13 @@ func NewDirectoryWatcher(parent task.Parent, dirPath string) *DirWatcher {
//! subdirectories are not watched
w, err := fsnotify.NewWatcher()
if err != nil {
logger.Panic().Err(err).Msg("unable to create fs watcher")
logging.Panic().Err(err).Msg("unable to create fs watcher")
}
if err = w.Add(dirPath); err != nil {
logger.Panic().Err(err).Msg("unable to create fs watcher")
logging.Panic().Err(err).Msg("unable to create fs watcher")
}
helper := &DirWatcher{
Logger: logger.With().
Logger: logging.With().
Str("type", "dir").
Str("path", dirPath).
Logger(),

View File

@@ -9,6 +9,7 @@ import (
"github.com/rs/zerolog"
D "github.com/yusing/go-proxy/internal/docker"
E "github.com/yusing/go-proxy/internal/error"
"github.com/yusing/go-proxy/internal/logging"
"github.com/yusing/go-proxy/internal/watcher/events"
)
@@ -55,7 +56,7 @@ func NewDockerWatcher(host string) DockerWatcher {
return DockerWatcher{
host: host,
clientOwned: true,
Logger: logger.With().
Logger: logging.With().
Str("type", "docker").
Str("host", host).
Logger(),
@@ -65,7 +66,7 @@ func NewDockerWatcher(host string) DockerWatcher {
func NewDockerWatcherWithClient(client *D.SharedClient) DockerWatcher {
return DockerWatcher{
client: client,
Logger: logger.With().
Logger: logging.With().
Str("type", "docker").
Str("host", client.DaemonHost()).
Logger(),

View File

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