mirror of
https://github.com/fullstorydev/grpcurl.git
synced 2026-05-23 04:01:45 +03:00
Print size of the message in very verbose mode (#181)
Adds -vv flag for "very verbose". Includes estimated message size when enabled. The size is an estimate because it is the canonical size for the proto message, but not necessarily its actual on-the-wire size.
This commit is contained in:
@@ -135,6 +135,8 @@ var (
|
||||
When describing messages, show a template of input data.`))
|
||||
verbose = flags.Bool("v", false, prettify(`
|
||||
Enable verbose output.`))
|
||||
veryVerbose = flags.Bool("vv", false, prettify(`
|
||||
Enable very verbose output.`))
|
||||
serverName = flags.String("servername", "", prettify(`
|
||||
Override server name when validating TLS certificate. This flag is
|
||||
ignored if -plaintext or -insecure is used.
|
||||
@@ -316,6 +318,14 @@ func main() {
|
||||
invoke = true
|
||||
}
|
||||
|
||||
verbosityLevel := 0
|
||||
if *verbose {
|
||||
verbosityLevel = 1
|
||||
}
|
||||
if *veryVerbose {
|
||||
verbosityLevel = 2
|
||||
}
|
||||
|
||||
var symbol string
|
||||
if invoke {
|
||||
if len(args) == 0 {
|
||||
@@ -651,7 +661,7 @@ func main() {
|
||||
// if not verbose output, then also include record delimiters
|
||||
// between each message, so output could potentially be piped
|
||||
// to another grpcurl process
|
||||
includeSeparators := !*verbose
|
||||
includeSeparators := verbosityLevel == 0
|
||||
options := grpcurl.FormatOptions{
|
||||
EmitJSONDefaultFields: *emitDefaults,
|
||||
IncludeTextSeparator: includeSeparators,
|
||||
@@ -661,7 +671,11 @@ func main() {
|
||||
if err != nil {
|
||||
fail(err, "Failed to construct request parser and formatter for %q", *format)
|
||||
}
|
||||
h := grpcurl.NewDefaultEventHandler(os.Stdout, descSource, formatter, *verbose)
|
||||
h := &grpcurl.DefaultEventHandler{
|
||||
Out: os.Stdout,
|
||||
Formatter: formatter,
|
||||
VerbosityLevel: verbosityLevel,
|
||||
}
|
||||
|
||||
err = grpcurl.InvokeRPC(ctx, descSource, cc, symbol, append(addlHeaders, rpcHeaders...), h, rf.Next)
|
||||
if err != nil {
|
||||
@@ -676,7 +690,7 @@ func main() {
|
||||
if h.NumResponses != 1 {
|
||||
respSuffix = "s"
|
||||
}
|
||||
if *verbose {
|
||||
if verbosityLevel > 0 {
|
||||
fmt.Printf("Sent %d request%s and received %d response%s\n", reqCount, reqSuffix, h.NumResponses, respSuffix)
|
||||
}
|
||||
if h.Status.Code() != codes.OK {
|
||||
|
||||
Reference in New Issue
Block a user