| package mirko |
| |
| import ( |
| "context" |
| "fmt" |
| |
| "github.com/golang/glog" |
| "golang.org/x/net/trace" |
| ) |
| |
| func TraceInfof(ctx context.Context, f string, args ...interface{}) { |
| tr, ok := trace.FromContext(ctx) |
| if !ok { |
| fmtd := fmt.Sprintf(f, args...) |
| glog.Infof("[no trace] %v", fmtd) |
| return |
| } |
| tr.LazyPrintf(f, args...) |
| } |
| |
| func TraceWarningf(ctx context.Context, f string, args ...interface{}) { |
| glog.Warningf(f, args...) |
| |
| tr, ok := trace.FromContext(ctx) |
| if ok { |
| tr.LazyPrintf(f, args...) |
| } |
| } |
| |
| func TraceErrorf(ctx context.Context, f string, args ...interface{}) { |
| glog.Errorf(f, args...) |
| |
| tr, ok := trace.FromContext(ctx) |
| if ok { |
| tr.LazyPrintf(f, args...) |
| } |
| } |