Skip to content

Commit

Permalink
Starting v2 release following API break
Browse files Browse the repository at this point in the history
In cd60aa4, we changed the API leading
to issues like:
```
src/k8s.io/client-go/transport/round_trippers.go:70:11: cannot convert klog.V(9) (type klog.Verbose) to type bool
```

So we should move to v2 of klog

Change-Id: Ibf270e0e6dd326fa91d18140e92139455cbe4de0
  • Loading branch information
dims committed Sep 19, 2019
1 parent cd60aa4 commit 2bed4d0
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 13 deletions.
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
language: go
go_import_path: k8s.io/klog
go_import_path: k8s.io/klog/v2
dist: xenial
go:
- 1.9.x
- 1.10.x
- 1.11.x
- 1.12.x
- 1.13.x
script:
- go get -t -v ./...
- diff -u <(echo -n) <(gofmt -d .)
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ How to use klog
- If you want to redirect everything logged using klog somewhere else (say syslog!), you can use `klog.SetOutput()` method and supply a `io.Writer`. (See `examples/set_output/usage_set_output.go`)
- For more logging conventions (See [Logging Conventions](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-instrumentation/logging.md))

**NOTE**: please use the newer go versions that support semantic import versioning in modules, ideally go 1.11.4 or greater.

### Coexisting with glog
This package can be used side by side with glog. [This example](examples/coexist_glog/coexist_glog.go) shows how to initialize and syncronize flags from the global `flag.CommandLine` FlagSet. In addition, the example makes use of stderr as combined output by setting `alsologtostderr` (or `logtostderr`) to `true`.

Expand Down
2 changes: 1 addition & 1 deletion examples/coexist_glog/coexist_glog.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"flag"

"github.com/golang/glog"
"k8s.io/klog"
"k8s.io/klog/v2"
)

func main() {
Expand Down
4 changes: 2 additions & 2 deletions examples/klogr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package main
import (
"flag"

"k8s.io/klog"
"k8s.io/klog/klogr"
"k8s.io/klog/v2"
"k8s.io/klog/v2/klogr"
)

type myError struct {
Expand Down
2 changes: 1 addition & 1 deletion examples/log_file/usage_log_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"flag"
"k8s.io/klog"
"k8s.io/klog/v2"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion examples/set_output/usage_set_output.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"flag"
"fmt"
"k8s.io/klog"
"k8s.io/klog/v2"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module k8s.io/klog
module k8s.io/klog/v2

go 1.12

Expand Down
2 changes: 1 addition & 1 deletion integration_tests/internal/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"fmt"
"os"

"k8s.io/klog"
"k8s.io/klog/v2"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion klog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func TestHeaderWithDir(t *testing.T) {
pid = 1234
Info("test")
var line int
format := "I0102 15:04:05.067890 1234 klog/klog_test.go:%d] test\n"
format := "I0102 15:04:05.067890 1234 v2/klog_test.go:%d] test\n"
n, err := fmt.Sscanf(contents(infoLog), format, &line)
if n != 1 || err != nil {
t.Errorf("log format error: %d elements, error %s:\n%s", n, err, contents(infoLog))
Expand Down
2 changes: 1 addition & 1 deletion klogr/klogr.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"sort"

"github.com/go-logr/logr"
"k8s.io/klog"
"k8s.io/klog/v2"
)

// New returns a logr.Logger which is implemented by klog.
Expand Down
2 changes: 1 addition & 1 deletion klogr/klogr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"flag"
"testing"

"k8s.io/klog"
"k8s.io/klog/v2"

"github.com/go-logr/logr"
)
Expand Down

0 comments on commit 2bed4d0

Please sign in to comment.