github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/server/debug/pprofui/ui.go (about) 1 // Copyright 2018 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License 4 // included in the file licenses/BSL.txt. 5 // 6 // As of the Change Date specified in that file, in accordance with 7 // the Business Source License, use of this software will be governed 8 // by the Apache License, Version 2.0, included in the file 9 // licenses/APL.txt. 10 11 package pprofui 12 13 import ( 14 "context" 15 "fmt" 16 "io" 17 18 "github.com/cockroachdb/cockroach/pkg/util/log" 19 "github.com/cockroachdb/logtags" 20 ) 21 22 func pprofCtx(ctx context.Context) context.Context { 23 return logtags.AddTag(ctx, "pprof", nil) 24 } 25 26 // fakeUI implements pprof's driver.UI. 27 type fakeUI struct{} 28 29 func (*fakeUI) ReadLine(prompt string) (string, error) { return "", io.EOF } 30 31 func (*fakeUI) Print(args ...interface{}) { 32 msg := fmt.Sprint(args...) 33 log.InfofDepth(pprofCtx(context.Background()), 1, "%s", msg) 34 } 35 36 func (*fakeUI) PrintErr(args ...interface{}) { 37 msg := fmt.Sprint(args...) 38 log.WarningfDepth(pprofCtx(context.Background()), 1, "%s", msg) 39 } 40 41 func (*fakeUI) IsTerminal() bool { 42 return false 43 } 44 45 func (*fakeUI) WantBrowser() bool { 46 return false 47 } 48 49 func (*fakeUI) SetAutoComplete(complete func(string) string) {}