hscloud/go/mirko/trace.go
Sergiusz Bazanski 1fad2e5c6e bgpwtf/cccampix: draw the rest of the fucking owl
Change-Id: I49fd5906e69512e8f2d414f406edc0179522f225
2019-08-11 23:43:25 +02:00

37 lines
674 B
Go

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.Info("[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...)
}
}