Skip to content

Commit

Permalink
Merge pull request #64 from muir/fiftytwo
Browse files Browse the repository at this point in the history
remove some debugging
  • Loading branch information
muir authored Sep 21, 2022
2 parents eeeaed7 + 2d3b422 commit 5d68513
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 42 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ test: $(ZZZGENERATED)
go test -v ./xopjson/... -tags xoptesting -run TestParameters -failfast $(TEST_ONLY)
go test -tags xoptesting ./... -failfast $(TEST_ONLY)
go test -tags xoptesting -race ./... -failfast $(TEST_ONLY)
XOPLEVEL_xoptestutil=warn go test -tags xoptesting ./xoptest/xoptestutil -run TestAdjustedLevelLogger
XOPLEVEL_xoptestutil=debug go test -tags xoptesting ./xoptest/xoptestutil -run TestAdjustedLevelLogger
XOPLEVEL_xoptestutil=warn go test -tags xoptesting ./xoptest/xoptestutil -run TestAdjustedLevelLogger -count 1
XOPLEVEL_xoptestutil=debug go test -tags xoptesting ./xoptest/xoptestutil -run TestAdjustedLevelLogger -count 1

${GOBIN}/gofumpt:;
go install mvdan.cc/gofumpt@latest
Expand Down Expand Up @@ -47,7 +47,7 @@ calculate_coverage:
rm profile.out; \
fi; \
done
XOPLEVEL_xoptestutil=debug go test -covermode=atomic -tags xoptesting -coverprofile=profile.out -coverpkg=github.com/muir/xop-go/... ./xoptest/xoptestutil -run TestAdjustedLevelLogger
XOPLEVEL_xoptestutil=debug go test -covermode=atomic -tags xoptesting -coverprofile=profile.out -coverpkg=github.com/muir/xop-go/... ./xoptest/xoptestutil -run TestAdjustedLevelLogger -count 1
if [ -f profile.out ]; then \
grep -v ^mode profile.out >> coverage.txt; \
rm profile.out; \
Expand Down
7 changes: 0 additions & 7 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package xop

import (
"context"
"fmt"
"os"
"path/filepath"
"runtime"
Expand Down Expand Up @@ -86,7 +85,6 @@ func AdjustedLevelLoger(getLogFromContext func(context.Context) *Log, level xopn
frame, _ := frames.Next()
var pkg string
if frame.Function != "" {
fmt.Println("XXX func", frame.Function)
// Example: github.com/muir/xop-go/xoptest/xoptestutil.init
if strings.HasSuffix(frame.Function, ".init") {
if i := strings.LastIndexByte(frame.Function, '/'); i != -1 {
Expand All @@ -100,26 +98,21 @@ func AdjustedLevelLoger(getLogFromContext func(context.Context) *Log, level xopn
pkg = p[0]
}
}
fmt.Println("XXX pkg =", pkg)
}
if pkg == "" {
fmt.Println("XXX file name", frame.File)
pkg = filepath.Base(filepath.Dir(frame.File))
if pkg == "." || pkg == "/" {
pkg = ""
}
}
if pkg != "" {
if ls, ok := os.LookupEnv("XOPLEVEL_" + pkg); ok {
fmt.Println("XXX found value", ls)
lvl, err := xopnum.LevelString(ls)
if err == nil {
level = lvl
} else if i, err := strconv.ParseInt(ls, 10, 64); err == nil {
level = xopnum.Level(i)
}
} else {
fmt.Println("XXX not set", "XOPLEVEL_"+pkg)
}
}
}
Expand Down
16 changes: 0 additions & 16 deletions seed.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ package xop

import (
"context"
"encoding/hex"
"fmt"
"time"

"github.com/muir/xop-go/trace"
Expand All @@ -20,40 +18,28 @@ type Seed struct {
// Copy makes a deep copy of a seed and also randomizes
// the SpanID.
func (seed Seed) Copy(mods ...SeedModifier) Seed {
fmt.Println("XXX Copy seed")
n := Seed{
spanSeed: seed.spanSeed.copy(true),
settings: seed.settings.Copy(),
}
if !seed.spanSet {
XXX := n.traceBundle.Trace.SpanID().String()
n.traceBundle.Trace.SpanID().SetRandom()
fmt.Println("XXX Copy randomize", XXX, "->", n.traceBundle.Trace.SpanID().String())
} else {
fmt.Println("XXX Copy w/o randomize")
}
n = n.applyMods(mods)
fmt.Println("XXX Copy final", n.traceBundle.Trace.SpanID().String())
return n
}

// Seed provides a copy of the current span's seed, but the
// spanID is randomized.
func (span *Span) Seed(mods ...SeedModifier) Seed {
fmt.Println("XXX Seed seed")
n := Seed{
spanSeed: span.seed.copy(false),
settings: span.log.settings.Copy(),
}
if !span.seed.spanSet {
XXX := n.traceBundle.Trace.SpanID().String()
n.traceBundle.Trace.SpanID().SetRandom()
fmt.Println("XXX Seed randomize", XXX, "->", n.traceBundle.Trace.SpanID().String())
} else {
fmt.Println("XXX Seed w/o randomize")
}
n = n.applyMods(mods)
fmt.Println("XXX Seed final", n.traceBundle.Trace.SpanID().String())
return n
}

Expand Down Expand Up @@ -166,15 +152,13 @@ func WithBundle(bundle trace.Bundle) SeedModifier {

func WithSpan(spanID [8]byte) SeedModifier {
return func(s *Seed) {
fmt.Println("XXX WithSpan", hex.EncodeToString(spanID[:]))
s.traceBundle.Trace.SpanID().Set(spanID)
s.spanSet = true
}
}

func WithTrace(trace trace.Trace) SeedModifier {
return func(s *Seed) {
fmt.Println("XXX WithTrace", trace.SpanID().String())
s.traceBundle.Trace = trace
s.traceSet = true
s.spanSet = true
Expand Down
16 changes: 0 additions & 16 deletions seed.zzzgo
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package xop

import (
"context"
"encoding/hex"
"fmt"
"time"

"github.com/muir/xop-go/trace"
Expand All @@ -18,40 +16,28 @@ type Seed struct {
// Copy makes a deep copy of a seed and also randomizes
// the SpanID.
func (seed Seed) Copy(mods ...SeedModifier) Seed {
fmt.Println("XXX Copy seed")
n := Seed{
spanSeed: seed.spanSeed.copy(true),
settings: seed.settings.Copy(),
}
if !seed.spanSet {
XXX := n.traceBundle.Trace.SpanID().String()
n.traceBundle.Trace.SpanID().SetRandom()
fmt.Println("XXX Copy randomize", XXX, "->", n.traceBundle.Trace.SpanID().String())
} else {
fmt.Println("XXX Copy w/o randomize")
}
n = n.applyMods(mods)
fmt.Println("XXX Copy final", n.traceBundle.Trace.SpanID().String())
return n
}

// Seed provides a copy of the current span's seed, but the
// spanID is randomized.
func (span *Span) Seed(mods ...SeedModifier) Seed {
fmt.Println("XXX Seed seed")
n := Seed{
spanSeed: span.seed.copy(false),
settings: span.log.settings.Copy(),
}
if !span.seed.spanSet {
XXX := n.traceBundle.Trace.SpanID().String()
n.traceBundle.Trace.SpanID().SetRandom()
fmt.Println("XXX Seed randomize", XXX, "->", n.traceBundle.Trace.SpanID().String())
} else {
fmt.Println("XXX Seed w/o randomize")
}
n = n.applyMods(mods)
fmt.Println("XXX Seed final", n.traceBundle.Trace.SpanID().String())
return n
}

Expand Down Expand Up @@ -164,15 +150,13 @@ func WithBundle(bundle trace.Bundle) SeedModifier {

func WithSpan(spanID [8]byte) SeedModifier {
return func(s *Seed) {
fmt.Println("XXX WithSpan", hex.EncodeToString(spanID[:]))
s.traceBundle.Trace.SpanID().Set(spanID)
s.spanSet = true
}
}

func WithTrace(trace trace.Trace) SeedModifier {
return func(s *Seed) {
fmt.Println("XXX WithTrace", trace.SpanID().String())
s.traceBundle.Trace = trace
s.traceSet = true
s.spanSet = true
Expand Down

0 comments on commit 5d68513

Please sign in to comment.