String returns a comma separated list of enabled categories
()
| 90 | |
| 91 | // String returns a comma separated list of enabled categories |
| 92 | func (t Trace) String() string { |
| 93 | if t == None { |
| 94 | return "none" |
| 95 | } |
| 96 | |
| 97 | s := "" |
| 98 | if t.Enabled(Perf) { |
| 99 | s += "perf," |
| 100 | } |
| 101 | if t.Enabled(CPU) { |
| 102 | s += "cpu," |
| 103 | } |
| 104 | if t.Enabled(Memory) { |
| 105 | s += "mem," |
| 106 | } |
| 107 | if t.Enabled(Opa) { |
| 108 | s += "opa," |
| 109 | } |
| 110 | if t.Enabled(Log) { |
| 111 | s += "log," |
| 112 | } |
| 113 | |
| 114 | return strings.TrimRight(s, ",") |
| 115 | } |
| 116 | |
| 117 | // WithTrace returns the context with the given Trace |
| 118 | func WithTrace(ctx context.Context, t Trace) context.Context { |