From 7586a697f6d50545cf9875d285a242cc5f3898fc Mon Sep 17 00:00:00 2001 From: Simon Eskildsen Date: Tue, 31 Mar 2015 11:24:31 -0400 Subject: [PATCH] readme: add example of context logging --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index f7b7aa9..be46da2 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,16 @@ func main() { "omg": true, "number": 100, }).Fatal("The ice breaks!") + + # A common pattern is to re-use fields between logging statements by re-using + # the logrus.Entry returned from WithFields() + contextLogger := log.WithFields(log.Fields{ + "common": "this is a common field", + "other": "I also should be logged always", + }) + + contextLogger.Info("I'll be logged with common and other field") + contextLogger.Info("Me too") } ```