package clog import ( "errors" "os" ) var errSome = errors.New("some error") func ExampleNew() { log := New(To(os.Stdout)) log.Info("info message with default options") log.Error(errSome, "error message with default options") log.Info("invalid key", 42, "answer") log.Info("missing value", "answer") log.Info("logging some maps", "map1", map[string]string{"key": "value", "op": "delete"}, "map2", map[string]string{"feeling": "less than map1", "key": "value"}, ) log.WithName("cli").WithName("subcommand").Info("coming from the deep", "kubectx", "ci-infra") // Output: // info message with default options // [error] error message with default options // err=some error // invalid key !(42)=answer // missing value answer=null // logging some maps // map1= // key value // op delete // map2= // feeling less than map1 // key value // cli:subcommand: coming from the deep kubectx=ci-infra } func ExampleNew_withCaller() { // Add caller information to all logs log := New(To(os.Stdout), WithCaller(All)) log.WithName("hello").WithName("world").Info("thanks for the fish") // Output: // hello:world: thanks for the fish }