Skip to content

Commit 3eeb80d

Browse files
committed
Use klog for logging in agent
1 parent 131dc7e commit 3eeb80d

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

cmd/agent/main.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import (
44
"encoding/json"
55
"fmt"
66
"net/http"
7-
"os"
87

98
"github.com/spf13/pflag"
9+
"k8s.io/klog/v2"
1010

1111
"github.com/diamondlightsource/dra-usbip-driver/pkg/devicemetadata"
1212
"github.com/diamondlightsource/dra-usbip-driver/pkg/kmod"
@@ -42,10 +42,10 @@ func listDevices(w http.ResponseWriter, req *http.Request) {
4242
if err != nil {
4343
// Log but don't error - need to continue on to
4444
// return list of other devices.
45-
fmt.Printf("Failed to bind device %s: %v\n", device, err)
45+
klog.Errorf("Failed to bind device %s: %s", device, err)
4646
continue
4747
}
48-
fmt.Printf("Bound device %s\n", device)
48+
klog.Infof("Bound device %s", device)
4949
}
5050

5151
devicesMetadata = append(devicesMetadata, udevInfo)
@@ -66,12 +66,10 @@ func main() {
6666

6767
moduleLoaded, err := kmod.IsLoaded("usbip_host")
6868
if err != nil {
69-
fmt.Println("Unable to check kernel modules: %s", err)
70-
os.Exit(1)
69+
klog.Fatalf("Unable to check kernel modules: %s", err)
7170
}
7271
if !moduleLoaded {
73-
fmt.Println("usbip_host kernel module is not loaded")
74-
os.Exit(1)
72+
klog.Fatal("usbip_host kernel module is not loaded")
7573
}
7674

7775
mux := http.NewServeMux()

0 commit comments

Comments
 (0)