Skip to content

Commit

Permalink
Migrate from glog to klog
Browse files Browse the repository at this point in the history
  • Loading branch information
tstromberg committed Apr 7, 2021
1 parent 0cc10ba commit aed2513
Show file tree
Hide file tree
Showing 7 changed files with 5,840 additions and 5,817 deletions.
25 changes: 13 additions & 12 deletions cmd/slowjam/slowjam.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"fmt"
"os"

"github.com/golang/glog"
"github.com/spf13/pflag"
"k8s.io/klog/v2"

"github.com/google/slowjam/pkg/pprof"
"github.com/google/slowjam/pkg/stacklog"
Expand All @@ -39,30 +39,31 @@ var (
)

func main() {
klog.InitFlags(nil)
pflag.Parse()

s := stacklog.MustStartFromEnv("STACKLOG_PATH")
defer s.Stop()

pflag.Parse()

if len(pflag.Args()) != 1 {
fmt.Fprintln(os.Stderr, "usage: slowjam [flags] <path>")
os.Exit(64) // EX_USAGE
}

f, err := os.Open(pflag.Args()[0])
if err != nil {
glog.Fatalf("open: %v", err)
klog.Fatalf("open: %v", err)
}

defer func() {
if err := f.Close(); err != nil {
glog.Errorf("close failed: %v", err)
klog.Errorf("close failed: %v", err)
}
}()

samples, err := stackparse.Read(f)
if err != nil {
glog.Fatalf("parse: %v", err)
klog.Fatalf("parse: %v", err)
}

tl := stackparse.CreateTimeline(samples, stackparse.SuggestedIgnore, *goroutines)
Expand All @@ -75,12 +76,12 @@ func main() {
if *htmlPath != "" {
w, err := os.Create(*htmlPath)
if err != nil {
glog.Exitf("open failed: %v", err)
klog.Exitf("open failed: %v", err)
}
defer w.Close()

if err := web.Render(w, tl); err != nil {
glog.Fatalf("render: %v", err)
klog.Fatalf("render: %v", err)
}

return
Expand All @@ -89,17 +90,17 @@ func main() {
if *pprofPath != "" {
w, err := os.Create(*pprofPath)
if err != nil {
glog.Exitf("open failed: %v", err)
klog.Exitf("open failed: %v", err)
}
defer w.Close()

bs, err := pprof.Render(samples, stackparse.SuggestedIgnore, *goroutines)
if err != nil {
glog.Fatalf("render: %v", err)
klog.Fatalf("render: %v", err)
}

if _, err := w.Write(bs); err != nil {
glog.Fatalf("write: %v", err)
klog.Fatalf("write: %v", err)
}

return
Expand All @@ -110,5 +111,5 @@ func main() {
return
}

glog.Exitf("no output mode specified")
klog.Exitf("no output mode specified")
}
Loading

0 comments on commit aed2513

Please sign in to comment.