Skip to content

Commit

Permalink
Add Context example.
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisHines committed Jul 13, 2015
1 parent acfd470 commit 1749c94
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions example_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package log_test

import (
"os"

"github.com/go-kit/kit/log"
)

func ExampleContext() {
logger := log.NewLogfmtLogger(os.Stdout)
logger.Log("foo", 123)
ctx := log.With(logger, "level", "info")
ctx.Log()
ctx = ctx.With("msg", "hello")
ctx.Log()
ctx.With("a", 1).Log("b", 2)

// Output:
// foo=123
// level=info
// level=info msg=hello
// level=info msg=hello a=1 b=2
}

0 comments on commit 1749c94

Please sign in to comment.