ctxlog is a Go library extending the standard context with logging.
- Create a child context that contains a log context.
- Helper functions to exit or panic when the provided context is cancelled.
- Consistent API with the context standard library.
package main
import (
"context"
"log"
"time"
l "github.com/jhulten/go-ctxlog"
)
func main() {
ctx := context.Background()
ctx = l.WithWriter(ctx, os.Stdout)
l.PLog(ctx).Info("logged this")
}