fork of go-git with some jj specific features

utils: trace, add Enabled method

Expose Enabled method to check if a trace target is enabled.

Changed files
+7 -2
utils
trace
+7 -2
utils/trace/trace.go
··· 69 69 70 70 // Print prints the given message only if the target is enabled. 71 71 func (t Target) Print(args ...interface{}) { 72 - if int32(t)&current.Load() != 0 { 72 + if t.Enabled() { 73 73 logger.Output(2, fmt.Sprint(args...)) // nolint: errcheck 74 74 } 75 75 } 76 76 77 77 // Printf prints the given message only if the target is enabled. 78 78 func (t Target) Printf(format string, args ...interface{}) { 79 - if int32(t)&current.Load() != 0 { 79 + if t.Enabled() { 80 80 logger.Output(2, fmt.Sprintf(format, args...)) // nolint: errcheck 81 81 } 82 82 } 83 + 84 + // Enabled returns true if the target is enabled. 85 + func (t Target) Enabled() bool { 86 + return int32(t)&current.Load() != 0 87 + }