blob: 7ec4e37d5745ef7a50074d8601e8cb10e86e0120 [file] [log] [blame]
Sergiusz Bazanski1fad2e52019-08-01 20:16:27 +02001package mirko
2
3import (
4 "context"
5 "fmt"
6
7 "github.com/golang/glog"
8 "golang.org/x/net/trace"
9)
10
11func TraceInfof(ctx context.Context, f string, args ...interface{}) {
12 tr, ok := trace.FromContext(ctx)
13 if !ok {
14 fmtd := fmt.Sprintf(f, args...)
Serge Bazanski88876552020-08-16 15:24:58 +020015 glog.Infof("[no trace] %v", fmtd)
Sergiusz Bazanski1fad2e52019-08-01 20:16:27 +020016 return
17 }
18 tr.LazyPrintf(f, args...)
19}
20
21func TraceWarningf(ctx context.Context, f string, args ...interface{}) {
22 glog.Warningf(f, args...)
23
24 tr, ok := trace.FromContext(ctx)
25 if ok {
26 tr.LazyPrintf(f, args...)
27 }
28}
29
30func TraceErrorf(ctx context.Context, f string, args ...interface{}) {
31 glog.Errorf(f, args...)
32
33 tr, ok := trace.FromContext(ctx)
34 if ok {
35 tr.LazyPrintf(f, args...)
36 }
37}