Skip to content

Commit

Permalink
Get rid of InfoLogger, implement V() as additive
Browse files Browse the repository at this point in the history
  • Loading branch information
thockin committed May 28, 2020
1 parent 7cfc60d commit 8b00636
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func main() {
log = log.WithName("MyName").WithValues("user", "you")
log.Info("hello", "val1", 1, "val2", map[string]int{"k": 1})
log.V(1).Info("you should see this")
log.V(3).Info("you should NOT see this")
log.V(1).V(1).Info("you should NOT see this")
log.Error(nil, "uh oh", "trouble", true, "reasons", []float64{0.1, 0.11, 3.14})
log.Error(E{"an error occurred"}, "goodbye", "code", -1)
}
5 changes: 2 additions & 3 deletions stdr.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ func (l logger) output(calldepth int, s string) {
}
}

func (l logger) V(level int) logr.InfoLogger {
func (l logger) V(level int) logr.Logger {
new := l.clone()
new.level = level
new.level += level
return new
}

Expand All @@ -205,4 +205,3 @@ func (l logger) WithValues(kvList ...interface{}) logr.Logger {
}

var _ logr.Logger = logger{}
var _ logr.InfoLogger = logger{}

0 comments on commit 8b00636

Please sign in to comment.