github.com/nikandfor/tlog@v0.21.5-0.20231108111739-3ef89426a96d/examples/simplest/main.go (about) 1 package main 2 3 import ( 4 "context" 5 "flag" 6 7 "github.com/nikandfor/tlog" 8 "github.com/nikandfor/tlog/examples/simplest/sub" 9 ) 10 11 var ( 12 f = flag.Int("f", 1, "int flag") 13 str = flag.String("str", "two", "string flag") 14 ) 15 16 func main() { 17 flag.Parse() 18 19 tlog.Printf("main: %d %q", *f, *str) 20 21 work(context.Background()) 22 } 23 24 func work(ctx context.Context) { 25 tr := tlog.Start("work_name") 26 defer tr.Finish() 27 28 ctx = tlog.ContextWithSpan(ctx, tr) 29 30 sub.Func(ctx, 9) 31 }