Move glog/klog logging to klog/v2

This commit is contained in:
Manuel Rüger
2023-09-07 17:24:13 +02:00
committed by Ciprian Hacman
parent eeab0ab06f
commit e43459d86d
56 changed files with 233 additions and 2530 deletions

View File

@@ -19,7 +19,7 @@ package makers
import (
"os"
"github.com/golang/glog"
"k8s.io/klog/v2"
)
func init() {
@@ -32,6 +32,6 @@ func makeFilesystemError() {
msg := []byte("fake filesystem error from problem-maker")
err := os.WriteFile(ext4ErrorTrigger, msg, 0200)
if err != nil {
glog.Fatalf("Failed writing log to %q: %v", ext4ErrorTrigger, err)
klog.Fatalf("Failed writing log to %q: %v", ext4ErrorTrigger, err)
}
}

View File

@@ -20,7 +20,7 @@ import (
"os"
"strings"
"github.com/golang/glog"
"k8s.io/klog/v2"
)
func init() {
@@ -40,7 +40,7 @@ func writeKernelMessageOrDie(msg string) {
for _, line := range strings.Split(msg, "\n") {
err := os.WriteFile(kmsgPath, []byte(line), 0644)
if err != nil {
glog.Fatalf("Failed writing to %q: %v", kmsgPath, err)
klog.Fatalf("Failed writing to %q: %v", kmsgPath, err)
}
}
}

View File

@@ -23,8 +23,8 @@ import (
"strings"
"time"
"github.com/golang/glog"
"github.com/spf13/pflag"
"k8s.io/klog/v2"
"k8s.io/node-problem-detector/test/e2e/problemmaker/makers"
)
@@ -54,7 +54,8 @@ func (o *options) AddFlags(fs *pflag.FlagSet) {
}
func main() {
// Set glog flag so that it does not log to files.
// Set klog flag so that it does not log to files.
klog.InitFlags(nil)
if err := flag.Set("logtostderr", "true"); err != nil {
fmt.Printf("Failed to set logtostderr=true: %v\n", err)
os.Exit(1)
@@ -65,12 +66,12 @@ func main() {
pflag.Parse()
if o.Problem == "" {
glog.Fatalf("Please specify the type of problem to make using the --problem argument.")
klog.Fatalf("Please specify the type of problem to make using the --problem argument.")
}
problemGenerator, ok := makers.ProblemGenerators[o.Problem]
if !ok {
glog.Fatalf("Expected to see a problem type of one of %q, but got %q.",
klog.Fatalf("Expected to see a problem type of one of %q, but got %q.",
makers.GetProblemTypes(), o.Problem)
}
@@ -89,7 +90,7 @@ func main() {
case <-done:
return
case <-ticker.C:
glog.Infof("Generating problem: %q", o.Problem)
klog.Infof("Generating problem: %q", o.Problem)
problemGenerator()
}
}