mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-22 16:28:30 +02:00
refactor: remove the use of logging module in most code
This commit is contained in:
@@ -8,8 +8,8 @@ import (
|
||||
|
||||
"github.com/fsnotify/fsnotify"
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/yusing/go-proxy/internal/gperr"
|
||||
"github.com/yusing/go-proxy/internal/logging"
|
||||
"github.com/yusing/go-proxy/internal/task"
|
||||
"github.com/yusing/go-proxy/internal/watcher/events"
|
||||
)
|
||||
@@ -41,13 +41,13 @@ func NewDirectoryWatcher(parent task.Parent, dirPath string) *DirWatcher {
|
||||
//! subdirectories are not watched
|
||||
w, err := fsnotify.NewWatcher()
|
||||
if err != nil {
|
||||
logging.Panic().Err(err).Msg("unable to create fs watcher")
|
||||
log.Panic().Err(err).Msg("unable to create fs watcher")
|
||||
}
|
||||
if err = w.Add(dirPath); err != nil {
|
||||
logging.Panic().Err(err).Msg("unable to create fs watcher")
|
||||
log.Panic().Err(err).Msg("unable to create fs watcher")
|
||||
}
|
||||
helper := &DirWatcher{
|
||||
Logger: logging.With().
|
||||
Logger: log.With().
|
||||
Str("type", "dir").
|
||||
Str("path", dirPath).
|
||||
Logger(),
|
||||
|
||||
@@ -8,9 +8,9 @@ import (
|
||||
docker_events "github.com/docker/docker/api/types/events"
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
"github.com/docker/docker/client"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/yusing/go-proxy/internal/docker"
|
||||
"github.com/yusing/go-proxy/internal/gperr"
|
||||
"github.com/yusing/go-proxy/internal/logging"
|
||||
"github.com/yusing/go-proxy/internal/watcher/events"
|
||||
)
|
||||
|
||||
@@ -81,7 +81,7 @@ func (w DockerWatcher) EventsWithOptions(ctx context.Context, options DockerList
|
||||
}()
|
||||
|
||||
cEventCh, cErrCh := client.Events(ctx, options)
|
||||
defer logging.Debug().Str("host", client.Address()).Msg("docker watcher closed")
|
||||
defer log.Debug().Str("host", client.Address()).Msg("docker watcher closed")
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
@@ -153,7 +153,7 @@ func checkConnection(ctx context.Context, client *docker.SharedClient) bool {
|
||||
defer cancel()
|
||||
err := client.CheckConnection(ctx)
|
||||
if err != nil {
|
||||
logging.Debug().Err(err).Msg("docker watcher: connection failed")
|
||||
log.Debug().Err(err).Msg("docker watcher: connection failed")
|
||||
return false
|
||||
}
|
||||
return true
|
||||
|
||||
@@ -7,9 +7,9 @@ import (
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/yusing/go-proxy/internal/docker"
|
||||
"github.com/yusing/go-proxy/internal/gperr"
|
||||
"github.com/yusing/go-proxy/internal/logging"
|
||||
"github.com/yusing/go-proxy/internal/notif"
|
||||
"github.com/yusing/go-proxy/internal/route/routes"
|
||||
"github.com/yusing/go-proxy/internal/task"
|
||||
@@ -48,7 +48,7 @@ func NewMonitor(r routes.Route) health.HealthMonCheck {
|
||||
case routes.StreamRoute:
|
||||
mon = NewRawHealthMonitor(&r.TargetURL().URL, r.HealthCheckConfig())
|
||||
default:
|
||||
logging.Panic().Msgf("unexpected route type: %T", r)
|
||||
log.Panic().Msgf("unexpected route type: %T", r)
|
||||
}
|
||||
}
|
||||
if r.IsDocker() {
|
||||
@@ -91,7 +91,7 @@ func (mon *monitor) Start(parent task.Parent) gperr.Error {
|
||||
mon.task = parent.Subtask("health_monitor", true)
|
||||
|
||||
go func() {
|
||||
logger := logging.With().Str("name", mon.service).Logger()
|
||||
logger := log.With().Str("name", mon.service).Logger()
|
||||
|
||||
defer func() {
|
||||
if mon.status.Load() != health.StatusError {
|
||||
@@ -221,7 +221,7 @@ func (mon *monitor) MarshalJSON() ([]byte, error) {
|
||||
}
|
||||
|
||||
func (mon *monitor) checkUpdateHealth() error {
|
||||
logger := logging.With().Str("name", mon.Name()).Logger()
|
||||
logger := log.With().Str("name", mon.Name()).Logger()
|
||||
result, err := mon.checkHealth()
|
||||
|
||||
var lastStatus health.Status
|
||||
|
||||
Reference in New Issue
Block a user