diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-03-16 14:15:45 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-03-16 14:15:45 +0000 |
commit | cd3c7908c2ca750b27d330b4d257edc6818c4a5d (patch) | |
tree | 194d7b0e539d014393564a256bec571e18d6533a /gopls/internal/lsp/debug/log/log.go | |
parent | 3225eca48f7ce16eb31b2dd5a170806c1214a49e (diff) | |
parent | 09c5a32afc5b66f28f166a68afe1fc71afbf9b73 (diff) | |
download | golang-x-tools-cd3c7908c2ca750b27d330b4d257edc6818c4a5d.tar.gz |
Snap for 9757917 from 09c5a32afc5b66f28f166a68afe1fc71afbf9b73 to build-tools-releasebuild-tools-release
Change-Id: If48e809642d94de846f47e34b88e446095e21aa5
Diffstat (limited to 'gopls/internal/lsp/debug/log/log.go')
-rw-r--r-- | gopls/internal/lsp/debug/log/log.go | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/gopls/internal/lsp/debug/log/log.go b/gopls/internal/lsp/debug/log/log.go new file mode 100644 index 000000000..e3eaa106f --- /dev/null +++ b/gopls/internal/lsp/debug/log/log.go @@ -0,0 +1,43 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package log provides helper methods for exporting log events to the +// internal/event package. +package log + +import ( + "context" + "fmt" + + "golang.org/x/tools/internal/event" + "golang.org/x/tools/internal/event/label" + "golang.org/x/tools/internal/event/tag" +) + +// Level parameterizes log severity. +type Level int + +const ( + _ Level = iota + Error + Warning + Info + Debug + Trace +) + +// Log exports a log event labeled with level l. +func (l Level) Log(ctx context.Context, msg string) { + event.Log(ctx, msg, tag.Level.Of(int(l))) +} + +// Logf formats and exports a log event labeled with level l. +func (l Level) Logf(ctx context.Context, format string, args ...interface{}) { + l.Log(ctx, fmt.Sprintf(format, args...)) +} + +// LabeledLevel extracts the labeled log l +func LabeledLevel(lm label.Map) Level { + return Level(tag.Level.Get(lm)) +} |