| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
package log |
| 8 |
|
| 9 |
import ( |
| 10 |
"context" |
| 11 |
"fmt" |
| 12 |
|
| 13 |
label1 "golang.org/x/tools/gopls/internal/label" |
| 14 |
"golang.org/x/tools/internal/event" |
| 15 |
"golang.org/x/tools/internal/event/label" |
| 16 |
) |
| 17 |
|
| 18 |
|
| 19 |
type Level int |
| 20 |
|
| 21 |
const ( |
| 22 |
_ Level = iota |
| 23 |
Error |
| 24 |
Warning |
| 25 |
Info |
| 26 |
Debug |
| 27 |
Trace |
| 28 |
) |
| 29 |
|
| 30 |
|
| 31 |
func (l Level) Log(ctx context.Context, msg string) { |
| 32 |
event.Log(ctx, msg, label1.Level.Of(int(l))) |
| 33 |
} |
| 34 |
|
| 35 |
|
| 36 |
func (l Level) Logf(ctx context.Context, format string, args ...any) { |
| 37 |
l.Log(ctx, fmt.Sprintf(format, args...)) |
| 38 |
} |
| 39 |
|
| 40 |
|
| 41 |
func LabeledLevel(lm label.Map) Level { |
| 42 |
return Level(label1.Level.Get(lm)) |
| 43 |
} |