2019-08-01 18:16:27 +00:00
|
|
|
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...)
|
2020-08-16 13:24:58 +00:00
|
|
|
glog.Infof("[no trace] %v", fmtd)
|
2019-08-01 18:16:27 +00:00
|
|
|
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...)
|
|
|
|
}
|
|
|
|
}
|