Skip to content

Commit 0d872c5

Browse files
committed
examplelog: Update to be a better example
Its best to defer the close right after checking Init's return so it isn't mistakingly forgotten. Also update the Package call so it matches the actual go package path.
1 parent e615d5c commit 0d872c5

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

cmd/examplelog/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ func main() {
1919
if err != nil {
2020
panic(err)
2121
}
22+
defer l.Close()
2223

23-
ll := l.Package("log")
24+
ll := l.Package("cmd/examplelog")
2425
ll.With("debug", true).Debug("hello this is a debug message")
2526
ll.With("debug", false).Info("hello this is a Info message")
2627

@@ -31,5 +32,4 @@ func main() {
3132
ll.Error(errors.WithMessage(err, "error with an extra WithMessage"))
3233

3334
helpfulWrapper(ll, "this is being called via helpfulWrapper")
34-
l.Close()
3535
}

0 commit comments

Comments
 (0)