bgpwtf/cccampix: draw the rest of the fucking owl
Change-Id: I49fd5906e69512e8f2d414f406edc0179522f225
diff --git a/go/mirko/trace.go b/go/mirko/trace.go
new file mode 100644
index 0000000..33b4352
--- /dev/null
+++ b/go/mirko/trace.go
@@ -0,0 +1,37 @@
+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...)
+ }
+}