@@ -3,8 +3,8 @@ package rtlsdr
33import (
44 "context"
55 "fmt"
6+ "log/slog"
67
7- "github.com/golang/glog"
88 "github.com/google/gousb"
99 pluginapi "k8s.io/kubelet/pkg/apis/deviceplugin/v1beta1"
1010)
@@ -29,11 +29,11 @@ func (p *Plugin) PreStartContainer(ctx context.Context, r *pluginapi.PreStartCon
2929func (p * Plugin ) UpdateDevices () error {
3030 rtls , err := ListDevices ()
3131 if err != nil {
32- glog . Infof ("Error listing devices: %s " , err . Error ( ))
32+ slog . Info ("Error listing devices" , slog . Any ( "error" , err ))
3333 return err
3434 }
3535
36- glog . Infof ("Found %d devices" , len (rtls ))
36+ slog . Info ("Found devices" , "len " , len (rtls ))
3737
3838 for _ , rtl := range p .RtlSdrs {
3939 rtl .Connected = false
@@ -68,31 +68,31 @@ func (p *Plugin) GetDevices() []*pluginapi.Device {
6868func (p * Plugin ) ListAndWatch (e * pluginapi.Empty , s pluginapi.DevicePlugin_ListAndWatchServer ) error {
6969 err := p .UpdateDevices ()
7070 if err != nil {
71- glog . Errorf ("Error listing devices: %s " , err . Error ( ))
71+ slog . Error ("Error listing devices" , slog . Any ( "error" , err ))
7272 }
7373
7474 devs := p .GetDevices ()
7575
7676 err = s .Send (& pluginapi.ListAndWatchResponse {Devices : devs })
7777 if err != nil {
78- glog . Errorf ("Error sending initial response: %s " , err . Error ( ))
78+ slog . Error ("Error sending initial response" , slog . Any ( "error" , err ))
7979 }
8080
81- glog .Info ("Waiting for updates..." )
81+ slog .Info ("Waiting for updates..." )
8282
8383 for range p .Heartbeat {
8484 err = p .UpdateDevices ()
8585 if err != nil {
86- glog . Errorf ("Error reading devices: %s " , err . Error ( ))
86+ slog . Error ("Error reading devices" , slog . Any ( "error" , err ))
8787 continue
8888 }
8989
9090 devs := p .GetDevices ()
91- glog . Infof ("Devices updated ( len %d) " , len (devs ))
91+ slog . Info ("Devices updated" , " len" , len (devs ))
9292
9393 err = s .Send (& pluginapi.ListAndWatchResponse {Devices : devs })
9494 if err != nil {
95- glog . Errorf ("Error sending response: %s " , err . Error ( ))
95+ slog . Error ("Error sending response" , slog . Any ( "error" , err ))
9696 continue
9797 }
9898 }
@@ -117,7 +117,7 @@ func (p *Plugin) Allocate(ctx context.Context, r *pluginapi.AllocateRequest) (*p
117117 car .Devices = append (car .Devices , dev )
118118
119119 for _ , id := range req .DevicesIDs {
120- glog . Infof ("Allocating device ID: %s " , id )
120+ slog . Info ("Allocating device" , slog . String ( "ID " , id ) )
121121
122122 dev .HostPath = p .RtlSdrs [id ].DevicePath ()
123123 dev .ContainerPath = p .RtlSdrs [id ].DevicePath ()
@@ -166,7 +166,7 @@ func ListDevices() ([]*RtlSdrDev, error) {
166166 }
167167
168168 if err != nil {
169- glog . Infof ( "Err open device (%d): %s" , len (devs ), err . Error ( ))
169+ slog . Info ( "Error open device" , slog . Int ( "len" , len (devs )), slog . Any ( "error" , err ))
170170 return nil , err
171171 }
172172
0 commit comments