Skip to content

Commit

Permalink
Add example
Browse files Browse the repository at this point in the history
  • Loading branch information
thockin committed Aug 13, 2019
1 parent 7536572 commit 0bd71cf
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions example/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package main

import "github.com/go-logr/zapr"
import "go.uber.org/zap"

type E struct {
str string
}

func (e E) Error() string {
return e.str
}

func main() {
log := zapr.NewLogger(zap.NewExample())
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.Error(nil, "uh oh", "trouble", true, "reasons", []float64{0.1, 0.11, 3.14})
log.Error(E{"an error occurred"}, "goodbye", "code", -1)
}

0 comments on commit 0bd71cf

Please sign in to comment.