Skip to content

Commit

Permalink
Use locally scoped slog loggers instead of default
Browse files Browse the repository at this point in the history
Cleans up some todos left during the logrus to slog conversion
process.
  • Loading branch information
rosstimothy committed Jan 10, 2025
1 parent 4a10f05 commit 13608a4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 19 deletions.
17 changes: 7 additions & 10 deletions lib/reversetunnel/srv.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,7 @@ func NewServer(cfg Config) (reversetunnelclient.Server, error) {
ResourceWatcherConfig: services.ResourceWatcherConfig{
Component: cfg.Component,
Client: cfg.LocalAccessPoint,
// TODO(tross): update this after converting to slog here
// Logger: cfg.Log,
Logger: cfg.Logger,
},
ProxiesC: make(chan []types.Server, 10),
ProxyGetter: cfg.LocalAccessPoint,
Expand Down Expand Up @@ -1211,10 +1210,9 @@ func newRemoteSite(srv *server, domainName string, sconn ssh.Conn) (*remoteSite,
remoteSite.remoteAccessPoint = accessPoint
nodeWatcher, err := services.NewNodeWatcher(closeContext, services.NodeWatcherConfig{
ResourceWatcherConfig: services.ResourceWatcherConfig{
Component: srv.Component,
Client: accessPoint,
// TODO(tross) update this after converting to use slog
// Logger: srv.Log,
Component: srv.Component,
Client: accessPoint,
Logger: srv.Logger,
MaxStaleness: time.Minute,
},
NodesGetter: accessPoint,
Expand Down Expand Up @@ -1247,10 +1245,9 @@ func newRemoteSite(srv *server, domainName string, sconn ssh.Conn) (*remoteSite,
remoteWatcher, err := services.NewCertAuthorityWatcher(srv.ctx, services.CertAuthorityWatcherConfig{
ResourceWatcherConfig: services.ResourceWatcherConfig{
Component: teleport.ComponentProxy,
// TODO(tross): update this after converting to slog
// Logger: srv.log,
Clock: srv.Clock,
Client: remoteSite.remoteAccessPoint,
Logger: srv.logger,
Clock: srv.Clock,
Client: remoteSite.remoteAccessPoint,
},
Types: []types.CertAuthType{types.HostCA},
})
Expand Down
4 changes: 1 addition & 3 deletions lib/srv/discovery/database_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package discovery

import (
"context"
"log/slog"
"sync"

"github.com/gravitational/trace"
Expand Down Expand Up @@ -54,8 +53,7 @@ func (s *Server) startDatabaseWatchers() error {
defer mu.Unlock()
return utils.FromSlice(newDatabases, types.Database.GetName)
},
// TODO(tross): update to use the server logger once it is converted to use slog
Logger: slog.With("kind", types.KindDatabase),
Logger: s.Log.With("kind", types.KindDatabase),
OnCreate: s.onDatabaseCreate,
OnUpdate: s.onDatabaseUpdate,
OnDelete: s.onDatabaseDelete,
Expand Down
5 changes: 2 additions & 3 deletions lib/srv/discovery/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -1869,9 +1869,8 @@ func (s *Server) getAzureSubscriptions(ctx context.Context, subs []string) ([]st
func (s *Server) initTeleportNodeWatcher() (err error) {
s.nodeWatcher, err = services.NewNodeWatcher(s.ctx, services.NodeWatcherConfig{
ResourceWatcherConfig: services.ResourceWatcherConfig{
Component: teleport.ComponentDiscovery,
// TODO(tross): update this after converting logging to use slog
// Logger: s.Logger,
Component: teleport.ComponentDiscovery,
Logger: s.Log,
Client: s.AccessPoint,
MaxStaleness: time.Minute,
},
Expand Down
4 changes: 1 addition & 3 deletions lib/srv/discovery/kube_services_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package discovery

import (
"context"
"log/slog"
"sync"
"time"

Expand Down Expand Up @@ -62,8 +61,7 @@ func (s *Server) startKubeAppsWatchers() error {
defer mu.Unlock()
return utils.FromSlice(appResources, types.Application.GetName)
},
// TODO(tross): update to use the server logger once it is converted to use slog
Logger: slog.With("kind", types.KindApp),
Logger: s.Log.With("kind", types.KindApp),
OnCreate: s.onAppCreate,
OnUpdate: s.onAppUpdate,
OnDelete: s.onAppDelete,
Expand Down

0 comments on commit 13608a4

Please sign in to comment.