Skip to content

Commit

Permalink
Fix logging when first arg is a context.Context without a logger
Browse files Browse the repository at this point in the history
  • Loading branch information
deluan committed Apr 26, 2020
1 parent b44218f commit 46f1b33
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions log/log.go
Expand Up @@ -180,6 +180,7 @@ func extractLogger(ctx interface{}) (*logrus.Entry, error) {
if logger != nil {
return logger.(*logrus.Entry), nil
}
return extractLogger(NewContext(ctx))
case *http.Request:
return extractLogger(ctx.Context())
}
Expand Down
4 changes: 2 additions & 2 deletions log/log_test.go
Expand Up @@ -41,8 +41,8 @@ var _ = Describe("Logger", func() {
Expect(hook.LastEntry().Data).To(BeEmpty())
})

XIt("Empty context", func() {
Error(context.Background(), "Simple Message")
It("Empty context", func() {
Error(context.TODO(), "Simple Message")
Expect(hook.LastEntry().Message).To(Equal("Simple Message"))
Expect(hook.LastEntry().Data).To(BeEmpty())
})
Expand Down

0 comments on commit 46f1b33

Please sign in to comment.